+ Reply to Thread
Results 1 to 9 of 9

Getting error 1004 Select method of range class failed when i automatically run my macro

  1. #1
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Getting error 1004 Select method of range class failed when i automatically run my macro

    At this moment i dont have a sample file that i can provide, if i can it would be next week and right now just looking for a quick solution until this is replaced.

    So something i noticed and not sure what is the best solution at this moment.
    When i run my macro, when it gets to this routine, i get this error:

    error 1004 Select method of range class failed
    On the 3rd line in the code below:
    "ThisWorkbook.Worksheets("Cleanup").Range("A2").Select"

    NOW, since it throws this error, if i simply select or make the "Cleanup" tab/sheet active, it will continue and complete successfully.

    Im working on redoing this routine, but that wont be for a few more days maybe next week. And i have the rest of this week i have to run this report.
    I havent had any issues with this until today, but today i swapped out another copy routine to use the advanced filter method to help speed things up.
    Ill be trying to implement the same in this routine, but like i said not yet..

    The only thing i can think is to add a "ThisWorkbook.Worksheets("Cleanup").Activate" before that line, but not sure thats the best solution. And then what will happen down towards the bottom when i need to paste the values into the other sheet "Mainrecords"

    Please Login or Register  to view this content.
    If you find the suggestion or solution helpful, please consider adding reputation to the post.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,599

    Re: Getting error 1004 Select method of range class failed when i automatically run my mac

    Probably just means the Cleanup sheet isn't selected when you run the routine whereas it was before you made the changes. I"ll try and look at it tomorrow if you haven’t had a better offer.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Getting error 1004 Select method of range class failed when i automatically run my mac

    For now ill just use the Activate until we replace routine, didnt seem to slow it down.
    We are trying to make the overall macro run quicker when we have days worth of files to open and copy into the MainRecords tab.

    So the below will also be replaced with the advanced filter method. Even with the routine below, the entire macro ran in under a second

    "This code ran successfully in 0.8 seconds"

    I ran it against a weeks worth of reports and the below didnt affects the overall performance much.

    8 files worth and ran in under 6 seconds
    "This code ran successfully in 5.87 seconds"

    Please Login or Register  to view this content.
    So the above temp solution will do until we can replace it with the other method. The whole reason for making these improvements was due to the fact that its typically done daily and when it is, only takes about 30 seconds, but on tuesday, had to process around 7 files and took little over 3 minutes.. so 5 secs is def ok for now.. and hopefully can be little faster when we replace this last routine.
    Last edited by cubangt; 06-09-2021 at 05:39 PM.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,599

    Re: Getting error 1004 Select method of range class failed when i automatically run my mac

    Ok, will look tomorrow when I’m in front of a computer.

  5. #5
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Getting error 1004 Select method of range class failed when i automatically run my mac

    Quote Originally Posted by TMS View Post
    Ok, will look tomorrow when I’m in front of a computer.
    ok, thank you

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,599

    Re: Getting error 1004 Select method of range class failed when i automatically run my mac

    Try:

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Getting error 1004 Select method of range class failed when i automatically run my mac

    I appreciate the response and have it saved, but actually got it working earlier today with the following change over to an array
    And that allowed the overall macro to complete in less than 1 second
    "This code ran successfully in 0.77 seconds"

    Please Login or Register  to view this content.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,599

    Re: Getting error 1004 Select method of range class failed when i automatically run my mac

    You're welcome. Thanks for the rep.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,599

    Re: Getting error 1004 Select method of range class failed when i automatically run my mac

    Not convinced your new code is quicker than mine. I tested your original code, your new code and my code against the same test data and my code consistently runs in half the time of the others. The Cleanup sheet has 26 columns by 2000 rows of data.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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] Run Time Error 1004 - Select method of Range class failed
    By jjmadore in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-17-2019, 04:50 AM
  2. [SOLVED] Run Time Error '1004': Select method of Range Class failed VBA
    By jcgonzales in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2014, 01:39 AM
  3. [SOLVED] error 1004 select method of range class failed
    By Lee_wwfc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-23-2013, 12:34 PM
  4. Run-time error '1004': Select method of Range class failed.
    By pspikym90 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-19-2012, 06:15 PM
  5. Run-time error '1004' - Select method of Range class failed
    By g10drac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-08-2011, 08:03 PM
  6. Error: Runtime 1004 - Select method of range class failed
    By additude in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2008, 05:58 PM
  7. [SOLVED] Runtime Error 1004 Select method of Range class Failed
    By IanO in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2005, 04:05 PM

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