+ Reply to Thread
Results 1 to 13 of 13

Macro in Excel 2016 runs MUCH slower when ANOTHER spreadsheet is open?

  1. #1
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Macro in Excel 2016 runs MUCH slower when ANOTHER spreadsheet is open?

    Greetings,

    I purchased a new, lightning fast computer this week, to replace a six year old system I had. I also purchased Excel 2016, since I no longer had the original 2007 Excel installation disks to install onto the new system.

    I've been playing with Excel 2016 now for a couple of days. Almost instantly, I noticed that with Excel 2016, one of my macros that took less than one second to run on my old, slow system using Excel 2007, now took about 26 seconds to run on my new system... with a much faster processor!

    WTF?!!

    The macro is actually quite simple. It doesn't write to the screen, it doesn't open any files, it doesn't loop through every row on the spreadsheet, etc.

    I spent time researching the problem and quickly found out that many others have had the same or similar problems, but none of their suggested solutions worked for me.

    However, I finally figured it out on my own. I noticed that if I CLOSE another spreadsheet that I just happened to have open at the same time, the macro would then run almost instantly... also less than one second to run!!

    Again, WTF??

    So my question is, does anyone know WHY having a second spreadsheet open (that incidentally doesn't contain any macros at all) causes the first spreadsheet's macro to take 26 times longer to run?

    The code is much too long to post here. But note that it doesn't access any other spreadsheets or files or anything like that.

    Idea: I think it might have something to do with Excel 2016's "feature" that another instance of Excel "appears" to be open, with each spreadsheet you have open. (With Excel 2016, you no longer have the option of having several spreadsheets open in the same window.) I say "appears," in quotes, because only one copy of Excel is actually open.

    As always, thanks in advance for any replies.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Why would a macro in Excel 2016 run MUCH slower when ANOTHER spreadsheet is open?

    I could only speculate that the other open workbook had lots of volatile formulas that recalculated every time the code made a change in the workbook it was operating on.

    I've not used Excel 2016 (or 2013), and there may be more afoot, but that aspect of behavior has never changed.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    06-16-2016
    Location
    Greece
    MS-Off Ver
    2013
    Posts
    69

    Re: Why would a macro in Excel 2016 run MUCH slower when ANOTHER spreadsheet is open?

    Idea: I think it might have something to do with Excel 2016's "feature" that another instance of Excel "appears" to be open, with each spreadsheet you have open. (With Excel 2016, you no longer have the option of having several spreadsheets open in the same window.) I say "appears," in quotes, because only one copy of Excel is actually open.
    Excel 2013 is the same in this aspect (you also can't have several workbooks in a single window) and I never noticed anything of the kind.

    Just curious, perhaps this might help, try adding
    Application.Cursor = xlWait
    in the beginning of the macro and
    application.Cursor =xlDefault
    at the end. See if it helps.
    Last edited by nick93; 09-17-2017 at 03:38 PM.

  4. #4
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: Why would a macro in Excel 2016 run MUCH slower when ANOTHER spreadsheet is open?

    Quote Originally Posted by nick93 View Post
    Just curious, perhaps this might help, try adding
    Application.Cursor = xlWait
    in the beginning of the macro and
    application.Cursor =xlDefault
    at the end. See if it helps.
    Nick,

    Thanks for the suggestion. I tried that and it did not help at all.

    I'll continue to experiment in my attempt to pinpoint exactly WHY it runs so much slower, just because another workbook (that is just sitting there doing nothing at all), is open.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro in Excel 2016 runs MUCH slower when ANOTHER spreadsheet is open?

    (that is just sitting there doing nothing at all)
    Every time you make a change to any cell, Excel recalculates all volatile formulas in all open workbooks.

    If you want to see if that's the problem, set the EnableCalculation property to False for all worksheets in that other workbook.

  6. #6
    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: Why would a macro in Excel 2016 run MUCH slower when ANOTHER spreadsheet is open?

    Quote Originally Posted by Ed_Collins View Post
    I'll continue to experiment in my attempt to pinpoint exactly WHY it runs so much slower, just because another workbook (that is just sitting there doing nothing at all), is open.
    Hi,

    Is it any other workbook being open, or one particular one?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  7. #7
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: Why would a macro in Excel 2016 run MUCH slower when ANOTHER spreadsheet is open?

    Quote Originally Posted by xlnitwit View Post
    Hi,

    Is it any other workbook being open, or one particular one?
    Good question. I opened up a bunch of other workbooks, and the macro ran fine, and so I was about to respond and say yes, it's just one particular workbook. But then I tried another one, that has a bunch of vlookup formulas, and sure enough, the workbook with the macro in question ran very, very slowly again.

    So no, the problem isn't related to a particular workbook.

  8. #8
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: Why would a macro in Excel 2016 run MUCH slower when ANOTHER spreadsheet is open?

    Quote Originally Posted by shg View Post
    ... set the EnableCalculation property to False for all worksheets in that other workbook.
    shg, forgive my ignorance but how do I do that?

    Recall that other workbook doesn't have any macro code at all... it's just an excel file with multiple worksheets, and yes, some of them do have formulas.

    It doesn't make any sense to make any changes to that workbook. (In fact, most of the time it most likely won't even be open when the workbook with the macro code is open and running. It just happened to be open at the time.)

    So I assume I need to add this EnableCalculation property to False code in the macro-enabled workbook. But when I do at the beginning of the macro, for the worksheet that is active, it doesn't help. It still runs horribly, horribly slowly, when the other workbook is open.

    I assume my code is wrong. Obviously I need to specifically say to enable calculation to false to any and all other workbooks that may (or may not) be open at the time. Can you tell me how to do that?

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro in Excel 2016 runs MUCH slower when ANOTHER spreadsheet is open?

    Please Login or Register  to view this content.
    It's just to find out if that's the problem.

  10. #10
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: Macro in Excel 2016 runs MUCH slower when ANOTHER spreadsheet is open?

    Okay shg, good work. (As usual.)

    I had a little bit of a problem compiling your code but I got the following to work:

    Please Login or Register  to view this content.
    And it did work. With the above code, the macro now runs almost (but not quite) as quickly as it does when the workbook isn't opened at all.

    So I guess that's the solution. I just need to turn off calculations for any workbooks that may or may not be open. Thanks.

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro in Excel 2016 runs MUCH slower when ANOTHER spreadsheet is open?

    Or write fewer volatile formulas.

  12. #12
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: Macro in Excel 2016 runs MUCH slower when ANOTHER spreadsheet is open?

    Quote Originally Posted by shg View Post
    Or write fewer volatile formulas.
    Ah. Yes. But if a user is using my workbook (the one with the macro), I wouldn't have any control over whatever workbooks they may or may not have open at the time. The other workbooks that are open wouldn't be mine.

    I wouldn't want my macro to crawl like a snail and take forever, just because they happen to have a bunch of volatile formulas in their own open workbooks.

    They wouldn't necessarily know the solution to the problem was to simply close their workbooks, and it would reflect back on me, thinking it was my macro that was just slow.

    This is why, even after I figured out what the problem was (another workbook being open), I wanted to know why.

    Thanks again.

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro in Excel 2016 runs MUCH slower when ANOTHER spreadsheet is open?

    You're welcome.

+ 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. Excel 2013 VBA - Operning CSV file in loop becomes slower and slower
    By maruthu22 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2017, 12:36 AM
  2. Excel Spreadsheet running VBA macros gets slower and slower over time
    By AliJay in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-20-2017, 01:31 AM
  3. Excel 2016 Mac - Open File Macro
    By DylanM in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-10-2016, 08:53 AM
  4. Excel macro getting slower and slower.
    By swoop99 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-24-2011, 06:41 AM
  5. macro runs much slower in excel 2007
    By hputhraya in forum Excel General
    Replies: 2
    Last Post: 03-25-2010, 03:54 AM
  6. [SOLVED] Embedded Excel macro runs 100X slower
    By JS in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-24-2006, 07:20 PM
  7. String manipulation in macro runs slower each time ran.
    By Lamination Technology in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-16-2006, 02:00 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