+ Reply to Thread
Results 1 to 16 of 16

Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

  1. #1
    Registered User
    Join Date
    10-03-2015
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    7

    Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    I have some VBA code that simply calculates an active sheet 10,000 times (a simple loop). Even though I have switched to manual calculation, screen updating off and read through numerous related posts/forums, when I have other specific workbooks open it causes my active workbook to be around 20 times slower - I have a timer in the code so that I can test.

    Ultimately, I need to run a Monte Carlo simulation, so 10,000 is actually a low number of calculations I would need to run. It's also quite important that the whole Active sheet calculates (so users can change the calculations in the sheet, and the VBA will just run it 10,000 times.

    This issue is consistent with different versions of excel, but I will say that not all open workbooks have the effect of slowing my code down. I am a fairly experienced Excel/VBA user, but am completely stumped... please help.

    Here is the code (very, very simple - also have attached the spreadsheet with the code):

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by ronelk; 10-04-2015 at 02:18 PM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    Maybe you should leave the calculation turned off, I run my programs with calculation set to manual and when I want a calculation, I just hit F9.

    AND, Welcome to the Forum!
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    10-03-2015
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    7

    Re: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    Thanks xladebt. Are you suggesting I push F9 10,000 times?

    As mentioned, my program is going to be a simulation, so I need to run the same calculation over and over (there will be random numbers involved). Also pushing F9 will surely calculate all the open workbooks, which I think is slower than my code. In my opinion my code/calculation should not be affected by other open workbooks in any way... I set the calculation to manual in VBA (i.e. turn off the calculation) and then only calculate the active sheet i.e. Activesheet.calculate.

    Please let me know if you need any more information to try help me with this. Thanks in advance.

  4. #4
    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: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    You might try eliminating or reducing the number of volatile formulas used in all workbooks, and closing all unnecessary workbooks.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    Hi ronelk,

    It seems that you're just counting from 1 to 10000 - so what's to calculate?

    it takes 0 time without the calculation

  6. #6
    Registered User
    Join Date
    10-03-2015
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    7

    Re: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    You are correct in that at the moment there is nothing being calculated in the active sheet - I posted it to be very simple on purpose to show that even with no calculations in the sheet this code/loop takes more than 5 seconds when I have other workbooks open (whereas without any other workbooks open it takes less than 0.5 seconds)... I wanted to avoid folks giving me solutions like the usual tips/tricks about volatile functions... etc (there are no functions being called in the activesheet). Obviously, I will have lots of calculations in the activesheet and other things in the loop (you can imagine how slow it gets when these are included).

    All I want is code that calculates my activesheet without being impacted by any other open workbooks... (seems simple enough, I know)

    I know a solution would be to just close all open workbooks, but this is a work around rather than a solution (also this is a model that will be used by lots of people, so a bit of a nuisance to tell everyone that they can only have this workbook open when using the model)... I just can't believe that there is no way for me to limit my calculations to one sheet (clearly excel is doing something when other workbooks are open).

    Thanks for your suggestions (please keep them coming).

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    Hi ronelk,

    The solution is to have VBA do the calculations it's nanoseconds vs milliseconds

    That's why I was looking for your formula!

  8. #8
    Registered User
    Join Date
    10-03-2015
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    7

    Re: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    I believe that is another workaround rather than a solution

    The idea is that users will customize their calculations in the active sheet and then VBA will just run these customized calculations 10,000 times and give the average (as well as other results). So putting all the calculations in VBA kind of defeats the purpose as the user does not know how to code, only how to use excel spreadsheets.

    ... I guess I'm really looking for some VBA code that actually switches off all other processes/calculations/everything except the sheet I want to calculate (switching to manual calculate and using Activesheet.calculate doesn't seem to be doing the trick) - I'm guessing there is something else I need to switch off from VBA.

  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: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    If nothing is changing in the other open workbooks, why are they taking time to recalculate?

  10. #10
    Registered User
    Join Date
    10-03-2015
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    7

    Re: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    Yep, this is my dilemma, I don't understand why simply just having another workbook open causes such a slowdown... it's not all workbooks that cause this problem (they usually have macros and sometimes data-tables... but should not be recalculating or have any impact on my active sheet/workbook, they are simply open). Like I said, I'm completely stumped .

  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: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    Like I said, do they contain volatile formulas?

  12. #12
    Registered User
    Join Date
    10-03-2015
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    7

    Re: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    Yes, it's possible that the open workbooks use volatile formulas... do you think despite setting the calculation to manual, and using the Activesheet.calculate command, that Excel recalculates volatile formulas in all open workbooks? Have you ever come across this problem/solution before?

    I just opened another workbook which I don't believe contains volatile functions (or VBA/Macros), and it slows down my original workbook I posted... so it doesn't seem like volatile functions are the culprit (the workbook does have a fair amount of calculations... but I don't think anything crazy) (I have attached the workbook that causes my original to slow down).

    Thanks for your help trying to figure this out.
    Attached Files Attached Files
    Last edited by ronelk; 10-03-2015 at 08:35 PM.

  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: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    I don't see any volatile formulas in the workbook (see http://www.decisionmodels.com/calcsecretsi.htm).

    Do you have sufficient memory installed, are you running other memory-hungry applications?

  14. #14
    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
    44,428

    Re: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    You have nearly 14000 formulae over 1415 rows, most of which simply test for blanks and return blanks, for example:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Not sure if a Natural Logarithm function is particularly resource hungry, but there's a lot of them.

    Looks like from column P to the right is currently serving no purpose, and the last 138 rows are "empty" but still with lots of formulae.

    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


  15. #15
    Registered User
    Join Date
    10-03-2015
    Location
    Georgia, USA
    MS-Off Ver
    2010
    Posts
    7

    Re: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    Thanks guys. I'd be interested to know if you are getting the same slowing down effect as I am? When I have just the original posted file open the loop takes less than 0.5 seconds, and when I have the other file opened as well, the loop takes close to 5 seconds. (If you guys experience the same issue, then that could eliminate any computer specific causes of this problem... although the only thing I do to cause the slowing down is just to open up another workbook - same things running.)

    To be clear this additional file is just one example of a file that causes my loop to slow down. I also have read up on volatile functions, as well as the various ways Excel calculates... by all accounts "activesheet.calculate" is supposed to only calculate the active sheet (and not be impacted by other open workbooks). Starting to think this is just a "bug" in Excel... perhaps I try send my issue directly to Microsoft? Has anyone had good experiences in sending issues directly to Microsoft? (Would love some advice).

  16. #16
    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
    44,428

    Re: Open workbooks causing active workbook to be very slow (tried all VBA tips/tricks)

    Don't know how much it helps but, for me, without the second workbook, it takes around 5 seconds; with the second workbook, between 6 and 9 seconds.

    Windows 7 64 bit, Excel 2007, 32 bit both fully patched

    Regards, TMS

+ 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 management - Tips and tricks
    By Goron in forum Excel General
    Replies: 1
    Last Post: 02-14-2015, 08:18 PM
  2. List of Tips & Tricks For SEO & PPC Management
    By sergio101bank in forum The Water Cooler
    Replies: 0
    Last Post: 05-01-2014, 02:55 PM
  3. [SOLVED] Open Multiple Workbooks, Record names, Copy paste to Active Workbook, Close the Workbooks
    By vba_madness in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2013, 06:09 AM
  4. Screen formatting tips and tricks?
    By Dr_Gzus in forum Excel General
    Replies: 4
    Last Post: 09-13-2012, 10:46 AM
  5. hints, tips, tricks for using workspace files
    By MrShorty in forum Excel General
    Replies: 2
    Last Post: 02-08-2006, 07:26 PM
  6. Excel TIPS&TRICKS and Samples
    By marko in forum Excel General
    Replies: 4
    Last Post: 11-30-2005, 03:25 PM
  7. [SOLVED] Tips and Tricks
    By Cathe in forum Excel General
    Replies: 1
    Last Post: 03-17-2005, 04:06 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