Turn off enable calculation

不羁的心 提交于 2021-01-29 16:13:29

问题


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.

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

回答1:


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.



来源:https://stackoverflow.com/questions/52856220/turn-off-enable-calculation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!