Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wait until Application.Calculate has finished

Tags:

excel

events

vba

Can I force my vba script to wait until Application.Calculate has finished to recalculate all the formulas?

like image 236
Sebastian Müller Avatar asked Jun 30 '12 19:06

Sebastian Müller


People also ask

How do you know if Excel is still calculating?

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.

What does Application calculation do in VBA?

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.

What is application wait?

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.

Does Excel VBA do until?

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.


1 Answers

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.

like image 116
Siddharth Rout Avatar answered Sep 21 '22 11:09

Siddharth Rout