Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
881 views
in Technique[技术] by (71.8m points)

events - Wait until Application.Calculate has finished

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...