+ Reply to Thread
Results 1 to 13 of 13

Macro has long runningtime

  1. #1
    Registered User
    Join Date
    06-29-2016
    Location
    Aarhus, Denmark
    MS-Off Ver
    2013 and 2016
    Posts
    23

    Macro has long runningtime

    Hello Everyone.

    I am using the following macro to add information of active assignments to a new sheet. HOWEVER the macro takes more then 15 seconds to run. Is there any way of shortening this?


    I appreciate any help. Thanks in Advance

    Cheers,

    Mads
    Please Login or Register  to view this content.

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Macro has long runningtime

    How about this?
    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

  3. #3
    Registered User
    Join Date
    06-29-2016
    Location
    Aarhus, Denmark
    MS-Off Ver
    2013 and 2016
    Posts
    23

    Re: Macro has long runningtime

    That's perfect Millz! Thanks a lot! (only 2-3 seconds)
    The macro is a part of multiple macros i run at the same time.
    I also have this macro which takes about 10 seconds. Any way of shortening this?

    Thanks in advance
    Cheers,
    Please Login or Register  to view this content.

  4. #4
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Macro has long runningtime

    You may try the remove duplicates function in Excel itself. If this doesn't work then let's modify your existing macro.


    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-29-2016
    Location
    Aarhus, Denmark
    MS-Off Ver
    2013 and 2016
    Posts
    23

    Re: Macro has long runningtime

    Hi Millz,

    That option doesn't seem to work.

    If you have any other solution please let me know
    Cheers

  6. #6
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Macro has long runningtime

    Were there any errors?

    How many rows of data is (usually) involved in the removal of duplicates?

    Would the number of rows ever exceed 32000?

  7. #7
    Registered User
    Join Date
    06-29-2016
    Location
    Aarhus, Denmark
    MS-Off Ver
    2013 and 2016
    Posts
    23

    Re: Macro has long runningtime

    I'm not sure how to use the new line of code you gave me.

    The data looks like this and is typically 100-400 rows
    Data.PNG

  8. #8
    Registered User
    Join Date
    06-29-2016
    Location
    Aarhus, Denmark
    MS-Off Ver
    2013 and 2016
    Posts
    23

    Re: Macro has long runningtime

    This is the error i get:
    Error.PNG

  9. #9
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Macro has long runningtime

    Hi,

    It would likely be considerably faster to use an array rather than reading each cell and further to delete all relevant rows at once.

    Please Login or Register  to view this content.
    Last edited by xlnitwit; 07-15-2016 at 04:01 AM. Reason: Amended per original specification
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  10. #10
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Macro has long runningtime

    Quote Originally Posted by madsklavsen View Post
    This is the error i get:
    Attachment 470439
    The error is because you have entered the code wrongly.

    Try this, just copy and paste the whole code:
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-29-2016
    Location
    Aarhus, Denmark
    MS-Off Ver
    2013 and 2016
    Posts
    23

    Re: Macro has long runningtime

    Okay thanks.

    However, i find that this is just a simple "remove duplicates" formula.
    What the beforestated macro does is delete the row of the duplicate AND delete the first appearance of a duplicate instead of the last. Both of these features are vital.

    Please let me know if you have any ideas. Thanks!

  12. #12
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Macro has long runningtime

    I see, did not know that there's a requirement to keep only the last duplicate record.

    This solution replaces with values (no deletion of rows), so it could be faster:
    Please Login or Register  to view this content.

  13. #13
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Macro has long runningtime

    Quote Originally Posted by madsklavsen View Post
    What the beforestated macro does is delete the row of the duplicate AND delete the first appearance of a duplicate instead of the last. Both of these features are vital.

    Please let me know if you have any ideas. Thanks!
    I have corrected the suggestion I made earlier to loop backwards.

+ 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. Problem with recording a macro with long formula - works in Excel but not in macro
    By tonybeo2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-28-2015, 11:25 AM
  2. Replies: 4
    Last Post: 09-16-2015, 08:07 AM
  3. [SOLVED] =IF and =SUMIF formulas creating long long long data processing times.
    By comp in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 03-26-2014, 02:59 PM
  4. Too Long of a formula for a macro?
    By melnemac32 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-08-2013, 02:30 PM
  5. Macro String too long
    By sam8114 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-25-2013, 12:17 PM
  6. Very long macro - Thanks
    By E3iron in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-09-2010, 01:00 PM
  7. Macro too long
    By John21 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-14-2006, 12:15 PM

Tags for this Thread

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