Macro Running Slow in Background

Eldrod

Board Regular
Joined
Mar 11, 2010
Messages
76
I have a macro that processes a lot of changes and can run anywhere from a few seconds to a few hours. I have a progress status bar that shows the cell count processed so I can see how fast its running. What I have discovered in testing is that when Excel is the program that has focus, it clips along as usual. But if I switch over to another program, the cell count almost stops. Switch back to Excel and it speeds back up.

Anyone know of any setting that could be causing this? TIA!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
My first suggestion would be to get rid of the Status Bar showing the cell count.
While that's a nice feature, it slows down performance immensely.

then, turn off Screenupdating and Calculation...

Put this at the beginning of your macro

Code:
With Application
    .ScreenUpdating = False
    PrvClc = .Calculation
    .Calculation = xlcalculationmanual
End with

And this at the end

Code:
With Application
    .ScreenUpdating = True
    .Calculation = PrvClc
End with

Hope that helps.
 
Upvote 0
Thanks! I already had screenupdating turned off, but when I added the calculation line set to manual, it went even slower (over twice as slow). On a whim, I changed the calculation mode to automatic and it runs quite fast again.
I still have the issue of it slowing when the program focus changes, but it didn't seem to be quite as bad. The progress status bar is really needed as it also provides a cancel button to stop a long running macro.
I was just wondering if there was anything else that slowed down Excel solely by changing program focus.
 
Upvote 0

Forum statistics

Threads
1,215,839
Messages
6,127,204
Members
449,368
Latest member
JayHo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top