vba 如何通过VBA刷新所有单元格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2370930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to refresh ALL cell through VBA
提问by Nimo
Is there anyway to trigger (from VBA) excel asking it to reevaluate ALL its excel cells ?
无论如何触发(来自VBA)excel要求它重新评估其所有excel单元格?
thank You
谢谢你
采纳答案by Neil Aitken
回答by almog.ori
Application.Volatile is a vba interpreter trick that only works when the call is placed directly after the method definition, after that Application.Calculate should reevaluate the function as well
Application.Volatile 是一个 vba 解释器技巧,只有在方法定义之后直接调用时才有效,之后 Application.Calculate 也应该重新评估函数
Public Function FooMethod()
Application.Volatile true
as the help states ...
正如帮助所述...
Marks a user-defined function as volatile. A volatile function must be recalculated whenever calculation occurs in any cells on the worksheet. A nonvolatile function is recalculated only when the input variables change. This method has no effect if it's not inside a user-defined function used to calculate a worksheet cell
将用户定义的函数标记为 volatile。每当工作表上的任何单元格中发生计算时,都必须重新计算 volatile 函数。只有当输入变量发生变化时,才会重新计算非易失性函数。如果此方法不在用于计算工作表单元格的用户定义函数内,则此方法无效
回答by Neil Knight
If you use the SendKeys method, you can use Shift+F9 to do this.
如果您使用 SendKeys 方法,则可以使用 Shift+F9 来执行此操作。