+ Reply to Thread
Results 1 to 7 of 7

Need Help Making Macro Faster/More Efficient

  1. #1
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Exclamation Need Help Making Macro Faster/More Efficient

    The below macro is incredibly slow, on my rather slow computer I calculated it will take about 21 hours to run the macro, which is just ridiculous, I could probably do it manually in the same time or faster.

    Is there any obvious way anyone sees to make this code faster?

    Also, the commented out part about deleting the rows seems to run into some sort of error I can't figure out....

    Thanks!

    Please Login or Register  to view this content.

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

    Re: Need Help Making Macro Faster/More Efficient

    Of course it is going to take forever. You have a loop within a loop doing 19000 loops, 648 times. So that is 12 million times you are running your code. Did you expect it to be instantaneous? Not only that but you didn't declare any variables so everything is running as a variant.

    A possible solution (not sure because we get no other information than your code. This is untested)

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Need Help Making Macro Faster/More Efficient

    I know it is going to take forever, and on top of that I still need to run the loop thats commented out... this is like the third time I've ever used VB or made a macro, and I havn't done any programming in years (and that was just basic classes in HS) its why i asked for help here....

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

    Re: Need Help Making Macro Faster/More Efficient

    Did the above amended macro work for your situation? If you want further assistance you will probably need to upload a copy of your workbook, with the sensitive material removed, so that we can get a better feel for what is going on.

  5. #5
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Need Help Making Macro Faster/More Efficient

    Quote Originally Posted by stnkynts View Post
    Did the above amended macro work for your situation? If you want further assistance you will probably need to upload a copy of your workbook, with the sensitive material removed, so that we can get a better feel for what is going on.

    It would be faster to make a dummy spreadsheet than remove the sensitive data which is virtually all of it.

    I have not had a chance to try it, but the bottom part that is commented out I solved myself, I was just missing an "End If" statement. But it seems to delete only a few rows that it should not all of them... ill post more info later when i have a chance to look at it some more thanks.

  6. #6
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Need Help Making Macro Faster/More Efficient

    On the delete row area....you may want to switch the startrow and endrow...when you are deleting rows like this the FOR loop counter gets confused and actually skips over rows because you have deleted a row and the FOR loop counter get incremented...so if you work backwards it should work...the other way is to keep the BeginRow and EndRow the same but inside the IF statement and after the actual Delete decrement DeleteRow....HTH

    Please Login or Register  to view this content.
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  7. #7
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Need Help Making Macro Faster/More Efficient

    Thanks thats all I needed to make this work properly, still slow, but I found a faster computer to run it on and it only takes 20 minutes to run on that computer.

    Quote Originally Posted by judgeh59 View Post
    On the delete row area....you may want to switch the startrow and endrow...when you are deleting rows like this the FOR loop counter gets confused and actually skips over rows because you have deleted a row and the FOR loop counter get incremented...so if you work backwards it should work...the other way is to keep the BeginRow and EndRow the same but inside the IF statement and after the actual Delete decrement DeleteRow....HTH

    Please Login or Register  to view this content.

+ 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] Sumproduct - formula more efficient/faster?
    By Gti182 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-17-2013, 07:45 AM
  2. [SOLVED] More efficient and faster way to delete Rows?
    By nironto in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-07-2013, 05:01 AM
  3. [SOLVED] Edit code to be faster, more efficient.
    By rocksan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-15-2012, 02:45 AM
  4. [SOLVED] Need Help Making Macro Run Faster
    By bigkahuna2187 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-08-2012, 07:38 AM
  5. Making Macro Run Faster
    By nalgene5622 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-18-2012, 10:26 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