werafa
03-03-2021, 06:57 PM
Hi all,
I am trying to check (and set to automatic) the calculation state when a workbook is opened.
I've created a personal macro workbook
I've written the following sub (which works) which is called by the workbook open event.
the problem is, when first opening excel, the workbook open event triggers before application.calculation is initialised.
does anyone have any advice?
thanks
Sub CheckCalculationState()
'read excel calculation state
'warn user if calculation is not automatic, and offer fix
Dim bIsAuto As Boolean
'ID calculation state
bIsAuto = False
If Application.Calculation = xlCalculationAutomatic Then bIsAuto = True
'warn/fix calculation state
If bIsAuto = False Then
Select Case MsgBox("xlCalculation is not set to automatic. Do you want to set it to set it to Automatic?", vbYesNo Or vbInformation, "clCalculation State")
Case vbYes
Application.Calculation = xlCalculationAutomatic
Case vbNo
'do nothing
End Select
End If
End Sub
I am trying to check (and set to automatic) the calculation state when a workbook is opened.
I've created a personal macro workbook
I've written the following sub (which works) which is called by the workbook open event.
the problem is, when first opening excel, the workbook open event triggers before application.calculation is initialised.
does anyone have any advice?
thanks
Sub CheckCalculationState()
'read excel calculation state
'warn user if calculation is not automatic, and offer fix
Dim bIsAuto As Boolean
'ID calculation state
bIsAuto = False
If Application.Calculation = xlCalculationAutomatic Then bIsAuto = True
'warn/fix calculation state
If bIsAuto = False Then
Select Case MsgBox("xlCalculation is not set to automatic. Do you want to set it to set it to Automatic?", vbYesNo Or vbInformation, "clCalculation State")
Case vbYes
Application.Calculation = xlCalculationAutomatic
Case vbNo
'do nothing
End Select
End If
End Sub