I have a rather large workbook, and some users prefer to have automatic calculation on, while others prefer having it off.
我有一个相当大的工作簿,一些用户喜欢使用自动计算,而另一些用户则喜欢关闭它。
Some macros that interact with the sheets are attatched to the workbook. To speed up my VBA code, I set
与表交互的一些宏被连接到工作簿中。为了加快VBA代码,我设置了
Application.Calculation = xlManual
In the beginning of each workbook.
在每个工作簿的开头。
My question is, how do I revert it back to the way it was in the end of macro?
我的问题是,我如何将它恢复到宏观的结尾?
Right now i'm using
现在我使用
Application.Calculation = xlAutomatic
but that overrides the users choice. It's pretty annoying having to change it back to manual every time the macro has run. (Or the other way around, if leaving it at manual.)
但这将覆盖用户的选择。每次运行宏时都要将它更改为manual,这很烦人。(或者反过来说,如果是手动的话。)
1 个解决方案
#1
4
Store the setting before starting, then restore when finished:
开始前存储设置,完成后还原:
Sub calctest()
Dim calcsetting As Integer
calcsetting = Application.Calculation
' Put code here
Application.Calculation = calcsetting
End Sub
#1
4
Store the setting before starting, then restore when finished:
开始前存储设置,完成后还原:
Sub calctest()
Dim calcsetting As Integer
calcsetting = Application.Calculation
' Put code here
Application.Calculation = calcsetting
End Sub