VBA loop slow if another workbook open

G

George

I have a longish do-while loop in a VBA fnc. (code, below) If only
this workbook is open, it completes in < 1 sec. If any other workbook
is open, execution time increases to many seconds.

My guess is that the 'application.calculate' is giving up the baton to
any other workbook, and the task switching is causing the slowdown. Is
this plausible?

Bottom line: ss there a way to speed this up? Any ideas would be
appreciated.

Thanks,
George

--------------------------------
Loop code:

Do
N = 200
Do
N = N - 1

Range("wt_use").Value = Range("wt_new").Value

Range("control").Value = _
Range("control").Value + Range("adj").Value

Application.Calculate
Loop While ((Abs(Range("min_err").Value) > 0.01) _
And (N > 0))
M = M + 1
Loop While ((Range("max_chg").Value > 0.01))
 
S

Stefi

Try this:

Application.Calculation = xlManual
Do
....
ActiveSheet.Calculate
Loop
Application.Calculation = xlAutomatic

Regards,
Stefi

„George†ezt írta:
 
G

George

Much better. Thanks.

G


Try this:

Application.Calculation = xlManual
Do
...
ActiveSheet.Calculate
Loop
Application.Calculation = xlAutomatic

Regards,
Stefi

„George” ezt írta:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top