+ Reply to Thread
Results 1 to 7 of 7

Macro optimization for speed

  1. #1
    Registered User
    Join Date
    09-21-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    13

    Macro optimization for speed

    Hi below I have a working but non-elegant macro by any means. I have a feeling the speed issues are related to having the ranges set all the way to the end of the workbook as opposed to the last row of data. Any improvements would be greatly appreciated. I have highlighted what I believe to be problematic areas.

    Thanks

    Please Login or Register  to view this content.

  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
    46,361

    Re: Macro optimization for speed

    I use:

    Please Login or Register  to view this content.

    to determine the last row of data. Use a column that will always have entries in every row, for example a key/ID field.

    Then replace all references to 1048575 with lLR.

    For example

    Please Login or Register  to view this content.


    Regards, TMS
    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
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro optimization for speed

    You're probably right. Did you try to modify them:

    ActiveSheet.Range("$A$2:$BM$" & Lastrow).RemoveDuplicates Columns:=3, Header:= _
    xlYes

    ActiveCell.FormulaR1C1 = "=COUNTIF(R[1]C:R[" & Lastrow & "]C,"">0"")"

    ActiveSheet.Range("$AK$1:$AK$" & Lastrow).AutoFilter Field:=1, Criteria1:= _
    "<>*fill*", Operator:=xlAnd

    And so on.

  4. #4
    Registered User
    Join Date
    09-21-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Macro optimization for speed

    Hi John,

    I applied your method it did work, shaved a little bit off the run-time not as much as i had been hoping for though unfortunately.

    Thank you though
    Much appreciated!

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Try changing the range for RemoveDuplicates.

    Also, get rid of Select.
    If posting code please use code tags, see here.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro optimization for speed

    You're welcome. Hope you take some of the other advice as well.

  7. #7
    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
    46,361

    Re: Macro optimization for speed

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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