+ Reply to Thread
Results 1 to 5 of 5

What causes a macro to run slower at certain times?

  1. #1
    Registered User
    Join Date
    06-20-2012
    Location
    Earth
    MS-Off Ver
    Excel 2010
    Posts
    15

    Question What causes a macro to run slower at certain times?

    I couldn't find anything that really answered this question specifically. When I run macros usually they're fast, but occasionally will run very slow. An example macro I have is pasted below. It's just a simple macro that pastes months. If I am pasting on top of a cell that contains a month it pastes the rest of the months that follow.

    Most of the time this macro runs very fast, but occasionally it takes about 1-2 seconds to run, and it is a very simple macro! It is not macro specific, as all my macros will be slow. I''m using Windows 7 with Excel 2010. I'm only using 23% of my CPU and 4.5GB of my 16GB of RAM, so I don't think it's a hardware thing.

    Is there some kind of condition that occurs that will make excel run macros slower? Any help is appreciated.

    Please Login or Register  to view this content.
    Last edited by Wegener; 04-02-2014 at 03:23 PM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: What causes a macro to run slower at certain times?

    It depends on what else is open - You should get into the habit of starting your code with this to prevent the slowdown that making changes to a cell by code can start:

    Please Login or Register  to view this content.
    And then finish up with this:

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    06-20-2012
    Location
    Earth
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: What causes a macro to run slower at certain times?

    Quote Originally Posted by Bernie Deitrick View Post
    It depends on what else is open - You should get into the habit of starting your code with this to prevent the slowdown that making changes to a cell by code can start:

    Please Login or Register  to view this content.
    And then finish up with this:

    Please Login or Register  to view this content.
    Thanks for these tips! Sped up my macro about 5x.

    I also closed a workbook with a lot of calcs in it and it ran a lot faster without the above tricks. Does every workbook recalc formulas when a macro runs? That would make sense to me why turning off auto calculation would speed things up.
    Last edited by Wegener; 04-02-2014 at 04:57 PM.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: What causes a macro to run slower at certain times?

    All workbooks can be re-calced, so having few or no others open is best: not always possible.

    The code captures whatever your calculation mode is currently using the line

    xlCalc = .Calculation

    It then turns it to manual, then final resets to your selection. You never want to assume a user prefers one over the others.

  5. #5
    Registered User
    Join Date
    04-20-2013
    Location
    Woking, England
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    34

    Re: What causes a macro to run slower at certain times?

    Hi

    Further to the comment within your code here is a variation :-
    Please Login or Register  to view this content.
    hth
    Mike

+ 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. Macros run slow after loading another workbook, and fast if I re-open Excel?
    By Pedsdude in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-19-2013, 10:17 AM
  2. identical macros run fast and slow
    By markwattwood in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-08-2005, 04:15 PM
  3. [SOLVED] Searches slow for some Fast for others?
    By [email protected] in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  4. [SOLVED] Searches slow for some Fast for others?
    By [email protected] in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  5. Searches slow for some Fast for others?
    By [email protected] in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 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