关闭启用计算 [英] Turn off enable calculation

查看:58
本文介绍了关闭启用计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作簿,其中包含许多不同的公式,并且其中有一个名为Map的工作表,每当我向不同的工作表中输入新数据时,我都不需要自动计算.我在此工作表下面有以下VBA代码.问题是我需要手动转到开发人员"选项卡,属性","EnableCalculation",然后选择"False".当我这样做时,代码可以完美运行.但是,当我关闭并重新打开工作簿时,属性"中的EnableCalculation已自动更改为True.打开工作簿时,我似乎无法拿出代码将此单独工作表上的此属性仅设置为False.

I have a workbook with a lot of different formulas and I have one worksheet in it called Map, that I need to not auto calculate, every time I enter new data into a different worksheet. I have the following VBA code below on this worksheet. The problem is I need to manually go to the Developer tab, Properties, EnableCalculation, and select False. When I do it this way, the code works perfectly. However when I close and re-open the workbook, the EnableCalculation in the Properties, has been automatically changed to True. I can't seem to come up with a code to turn this Property on this individual sheet only to False upon opening the workbook.

任何有关如何执行此操作的建议将不胜感激.我是编码的新手,因为这是我第一次尝试编写VBA代码,花了我几天时间才得到下面的内容.因此,描述性越强越好.谢谢!

Any suggestions on how to do this would be appreciated. I am new to coding, like this is my first time trying to write a VBA code and its taken me days to just get what I have below. So the more descriptive the better. Thank you!

Sub docalc()
Dim oldCalc As Boolean
oldCalc = ActiveSheet.EnableCalculation
ActiveSheet.EnableCalculation = False
ActiveSheet.EnableCalculation = True
ActiveSheet.EnableCalculation = oldCalc
End Sub

推荐答案

插入名为 Sub Workbook_Open()的模块,并添加 ws.EnableCalculation = False 行,其中ws是您要为其设置属性的工作表,例如 worksheets("Sheet4") worksheets(4).每次打开工作簿时,都会自动运行Workbook_Open()子项.

Insert a module called Sub Workbook_Open() and add the line ws.EnableCalculation = False where ws is whichever worksheet you want to set the property for--for example worksheets("Sheet4") or worksheets(4). The Workbook_Open() sub will run automatically every time the workbook is opened.

这篇关于关闭启用计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆