等到 Application.Calculate 完成 [英] Wait until Application.Calculate has finished
问题描述
我可以强制我的 vba 脚本等到 Application.Calculate 完成重新计算所有公式吗?
Can I force my vba script to wait until Application.Calculate has finished to recalculate all the formulas?
推荐答案
根据我的评论,您可以将 DoEvents 与 Application.CalculationState
一起使用.看这个例子
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.
如果你愿意,你也可以使用 Do While Loop
来检查 Application.CalculationState
If you want you can also use a Do While Loop
to check for Application.CalculationState
我也建议查看此链接
主题:Application.CalculationState 属性
Topic: Application.CalculationState Property
链接:http://msdn.microsoft.com/en-us/library/bb220901%28v=office.12%29.aspx
从上面的链接引用
返回一个 XlCalculationState 常量,该常量指示应用程序的计算状态,用于在 Microsoft Excel 中执行的任何计算.只读.
Returns an XlCalculationState constant that indicates the calculation state of the application, for any calculations that are being performed in Microsoft Excel. Read-only.
这篇关于等到 Application.Calculate 完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!