宏:激活"自动计算"打开excel工作簿时

时间:2015-08-19 14:36:13

标签: excel vba excel-vba

如何激活选项"自动计算"直接用宏打开excel工作簿后?

1 个答案:

答案 0 :(得分:3)

打开VB编辑器( ALT + F11 )并右键单击ThisWorkbook(在Microsoft Excel对象下) - >查看代码。

此区域处理工作簿事件代码。

粘贴以下代码:

Private Sub Workbook_Open()
        Application.Calculation = xlCalculationAutomatic
End Sub

这只会更改Excel设置以自动进行计算。如果你想在开放时实际计算工作簿,你可以这样做:

Private Sub Workbook_Open()
        Application.Calculation = xlCalculationAutomatic 'Change calculation setting to automatic
        Application.Calculate 'Perform workbook calculations
End Sub