+ Reply to Thread
Results 1 to 7 of 7

Run-time error '1004' - code failing when on a different sheet

  1. #1
    Forum Contributor
    Join Date
    08-03-2009
    Location
    Cary, NC
    MS-Off Ver
    Excel 2016
    Posts
    109

    Run-time error '1004' - code failing when on a different sheet

    I'm running the following code:

    Please Login or Register  to view this content.
    The code works fine as long as I'm on sheet Level1. But if I'm on a different sheet I get the error: Run-time error '1004': Select method of Range class failed. I have a userform on a different sheet with a button that calls this procedure. I want to run this procedure and switch to sheet Level1 AFTER it has run. How do I do that?
    Last edited by bishoposiris; 02-10-2016 at 12:51 PM. Reason: Solved

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Run-time error '1004' - code failing when on a different sheet

    Which line of code causes the error?
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Run-time error '1004' - code failing when on a different sheet

    Off the top of my head I would guess this line is the issue:

    Please Login or Register  to view this content.
    I could be wrong though.
    If you are happy with my response please click the * in the lower left of my post.

  4. #4
    Forum Contributor
    Join Date
    08-03-2009
    Location
    Cary, NC
    MS-Off Ver
    Excel 2016
    Posts
    109

    Re: Run-time error '1004' - code failing when on a different sheet

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Run-time error '1004' - code failing when on a different sheet

    You can't select a range on a non active sheet. That line doens't do anything anyways so delete it and see what the next errored line is.

  6. #6
    Forum Contributor
    Join Date
    08-03-2009
    Location
    Cary, NC
    MS-Off Ver
    Excel 2016
    Posts
    109

    Re: Run-time error '1004' - code failing when on a different sheet

    Deleted it and the next error was on the next range selection. I'll just activate the worksheet before the first range selection.

    Thanks.

  7. #7
    Forum Contributor
    Join Date
    08-03-2009
    Location
    Cary, NC
    MS-Off Ver
    Excel 2016
    Posts
    109

    Re: Run-time error '1004' - code failing when on a different sheet

    Deleted it and the next error was on the next range selection. I'll just activate the worksheet before the first range selection.

    Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macros must be enabled code failing with Run Time Error 57121
    By leaning in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-30-2016, 11:25 AM
  2. Run Time Error 1004 (VBA Code)
    By Cheezee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-26-2015, 04:47 PM
  3. Replies: 4
    Last Post: 11-15-2013, 05:03 PM
  4. VBA Code...error = run time error 1004 autofilter method of range class failed
    By Dariusd7 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-15-2013, 04:49 PM
  5. ActiveSheet.Paste failing(Runtime error '1004')
    By sanjeevap in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-12-2013, 12:58 PM
  6. Run Time Error 1004 on code
    By aftabn10 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-24-2011, 09:46 AM
  7. Code Run-time error '1004'
    By superbob in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2010, 09:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1