Wait until Application.Calculate has finished

2020-01-27 05:40发布

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

1条回答
Melony?
2楼-- · 2020-01-27 05:46

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.

查看更多
登录 后发表回答