I run a book with over 200,000 formulas (some very complex array formulas), which means that I cannot let Excel automatically calculate all cells every time I click somewhere (it takes about 8 hours to calculate everything).
Instead, the calculation is set to manual mode, and when you run Calculation.xlsm, the following VBA code is executed:
With Application
.CalculateBeforeSave = False
.Calculation = xlCalculationManual
End With
I use custom buttons to calculate only some parts of 200k cells when needed.
I noticed that Excel tracks this setting in every workbook, which means that if I open my Calculation.xlsm, Excel remembers that the calculation is set to manual. If I open my Values.xlsx file, Excel remembers that the calculation is set to automatic. This was before I tried to copy the values from Calculation.xlsm to Values.xlsx.
Now, since I use VBA in Calculation.xlsm to copy values to Values.xlsx, Excel also applies the parameter Application.Calculationto this workbook , which means that if I open it using a new Excel instance, the calculation will still be set manually.
If I add Application.Calculation = xlCalculationAutomaticValues.xlsx with VBA before closing Calculation.xlsm in my workbook, it will work, but Excel will also start calculating 200k cells in my Calculation.xlsm workbook, which I obviously don’t want.
, , Excel , Application. , Excel , ( 2 .xlsx, , , Excel ).
, Worksheets.Range.Calculate Values.xlsx , - , Excel .
3:20 : , , . , Calculation.xlsm VBA Calculation, . Values.xlsx VBA, Calculation - . Values.xlsx VBA Calculation.xlsm, Excel Values.xlsx .
Calculation.xlsm code:
Private Sub Workbook_Open()
With Application
.CalculateBeforeSave = False
.Calculation = xlCalculationManual
End With
End Sub
Sub someFunction()
Set WB = Application.Workbooks.Open("Values.xlsx")
Set WBws = WB.Sheets("mySheet")
DoEvents
wb.Save
WB.Close
End Sub
someFunction() Values.xlsx . . , ( VBA , Calculation.xlsm, ).
3:40 . Application.Calculation , , ( , ), ( VBA , , ?), Application.Calculation Auto ( ), , ( Excel , ?), , ( ) , ?