是否可以在 VBA 中仅重新计算单元格或范围
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8342012/
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
is it possible to recalculate only a cell or a range in VBA
提问by BuZz
is it possible to recalculate only a cell or a range in VBA ? What I like to use for a sheet is the following, but how to do it on a cell only ? Or range ?
是否可以在 VBA 中仅重新计算单元格或范围?我喜欢用于工作表的内容如下,但如何仅在单元格上使用?还是范围?
' ActiveSheet.EnableCalculation = False
' ActiveSheet.EnableCalculation = True
回答by aevanko
There is a calculate method you can call on ranges:
有一个计算方法可以调用范围:
Range("A1").Calculate
Try it out by putting =Now() in A1 and running Calculate and watch it update the seconds :) You can for a recalc of all the cells in a sheet by using:
通过将 =Now() 放入 A1 并运行计算并观察它更新秒数来尝试一下:) 您可以使用以下方法重新计算工作表中的所有单元格:
Sheets(1).Calculate
See also: Microsoft MSDN, Excel Recalculation, 16 July 2012.
另请参阅:Microsoft MSDN,Excel 重新计算,2012 年 7 月 16 日。
回答by Unicco
Requirements: Application.Calculation = xlManual
要求: Application.Calculation = xlManual
Calculate: All open workbooks
计算:所有打开的工作簿
Application.Calculate
Calculate: A specific worksheet
计算:特定工作表
Worksheets(1).Calculate
or
或者
Worksheets("sheetname").Calculate
Calculate: A specified row
计算:指定行
Worksheets(1).Rows(2).Calculate
or
或者
Worksheets("sheetname").Range("A1").EntireRow.Calculate
It's not possible to recalculate just one specific cell, like for instance only Range("A1").
不可能只重新计算一个特定的单元格,例如仅重新计算 Range("A1")。