RafFiniert
New Member
- Joined
- Mar 18, 2025
- Messages
- 7
- Office Version
- 2013
- Platform
- Windows
I'm happy to read the answer somewhere else if this has already been answered. However, so far, I've been unable to find it.
Problem:
VBA's speed of processing can outstrip the pace of xls processing, necessitating some method of delay in the VBA code
Conventional wisdom:
Set these...
Application.DisplayAlerts = False
Application.DisplayStatusBar = False
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Then manually recalculate sheets as needed.
If the VBA code is still proceeding before the manual recalculations complete, use Wait, Delay, or Loop to force a delay.
I have tried these with varying degrees of success. What bothers me is that waiting for a definitive period of time seems so inefficient--since you have to account for a worst-case scenario. (And the worst-case scenario might vary widely--especially if you're waiting for something to return from a webservice call, which also introduces the speed of your internet connection as a variable.)
It seems like there should be something that says to "wait until processing complete." So far, I haven't found it.
The only thing I have found that works is to do the manual recalculations and then ThisWorkbook.Save (and, yes, I understand that if Application.CalculateBeforeSave is set to True, the manual recalculations are redundant). It seems that the VBA code won't proceed until the save step is complete.
Is there a more elegant solution?
Problem:
VBA's speed of processing can outstrip the pace of xls processing, necessitating some method of delay in the VBA code
Conventional wisdom:
Set these...
Application.DisplayAlerts = False
Application.DisplayStatusBar = False
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Then manually recalculate sheets as needed.
If the VBA code is still proceeding before the manual recalculations complete, use Wait, Delay, or Loop to force a delay.
I have tried these with varying degrees of success. What bothers me is that waiting for a definitive period of time seems so inefficient--since you have to account for a worst-case scenario. (And the worst-case scenario might vary widely--especially if you're waiting for something to return from a webservice call, which also introduces the speed of your internet connection as a variable.)
It seems like there should be something that says to "wait until processing complete." So far, I haven't found it.
The only thing I have found that works is to do the manual recalculations and then ThisWorkbook.Save (and, yes, I understand that if Application.CalculateBeforeSave is set to True, the manual recalculations are redundant). It seems that the VBA code won't proceed until the save step is complete.
Is there a more elegant solution?