Can I force my vba script to wait until Application.Calculate has finished to recalculate all the formulas?
Show activity on this post. On the status bar, right hand side, it will say Calculating (N processors) X% (where N is the number of processors on your computer and X% is how much it has completed) when recalculating. If you don't see text there, it's not recalculating.
Calculates all open workbooks, a specific worksheet in a workbook, or a specified range of cells on a worksheet, as shown in the following table.
The VBA Application. Wait is a native VBA function that pauses code execution until a certain time is reached. As opposed to VBA Sleep, the Application Wait procedure does not freeze Excel during the pause. This means you can keep working on your Excel Workbook during the delay.
The Do Until loop is a useful tool in Excel VBA used to repeat a set of steps until the statement is FALSE. When the statement is FALSE we want the loop to stop and the loop naturally comes to an end. So in phrasing the loop the condition is set at the end of the loop.
Further to my comments, you can use DoEvents with the Application.CalculationState
. See this example
Application.Calculate If Not Application.CalculationState = xlDone Then DoEvents End If '~~> Rest of the code.
If you want you can also use a Do While Loop
to check for Application.CalculationState
I would also recommend see this link
Topic: Application.CalculationState Property
Link: http://msdn.microsoft.com/en-us/library/bb220901%28v=office.12%29.aspx
Quote From the Above Link
Returns an XlCalculationState constant that indicates the calculation state of the application, for any calculations that are being performed in Microsoft Excel. Read-only.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With