Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default VBA loop slow if another workbook open

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))


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default VBA loop slow if another workbook open

Try this:

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

Regards,
Stefi

€˛George€¯ ezt Ć*rta:

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))



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default VBA loop slow if another workbook open

Much better. Thanks.

G


On Mon, 29 Sep 2008 05:09:01 -0700, Stefi
wrote:

Try this:

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

Regards,
Stefi

„George” ezt ķrta:

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. ...



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default VBA loop slow if another workbook open

You are welcome! Thanks for the feedback!
Stefi

€˛George€¯ ezt Ć*rta:

Much better. Thanks.

G


On Mon, 29 Sep 2008 05:09:01 -0700, Stefi
wrote:

Try this:

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

Regards,
Stefi

€˛George€¯ ezt Ć*rta:

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. ...




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
file won't open, endless loop, autorecover lindalou Excel Discussion (Misc queries) 1 January 20th 08 01:26 AM
open files in loop with date order [email protected] Excel Discussion (Misc queries) 5 September 24th 07 01:10 AM
Loop time seems dependent on unrelated workbook - Why? Richard Excel Worksheet Functions 2 March 30th 06 11:59 PM
Excel Workbook slow to open Sandy M Excel Discussion (Misc queries) 2 January 9th 06 09:11 PM
copy,paste and loop through workbook TUNGANA KURMA RAJU Excel Discussion (Misc queries) 0 December 6th 05 12:31 PM


All times are GMT +1. The time now is 01:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"