Toggle AutoCalc

S

Sandy

The following simple routines turn off/on Auto Calc
Sub AutoCalcOff()
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
End Sub

Sub AutoCalcOn()
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
End Sub

How can I combine the 2 and toggle between on and off with a shortcut
key...Unless of course this is built into Excel already. I know If I switch
to manual that F9 will recalc but I want to be able to turn off and on via
shortcut key. And a recalc when It is turned on would be nice too :)
Thanks!
 
J

JE McGimpsey

One way:

Assign this to your shortcut key:

Public Sub ToggleCalc()
ActiveWorkbook.PrecisionAsDisplayed = False
With Application
If .Calculation = xlCalculationManual Then
.Calculation = xlCalculationAutomatic
Else
.Calculation = xlCalculationManual
.MaxChange = 0.001
End If
End With
End Sub

Setting Calculation to automatic will automatically recalc.
 
S

Sandy

Thank you!

JE McGimpsey said:
One way:

Assign this to your shortcut key:

Public Sub ToggleCalc()
ActiveWorkbook.PrecisionAsDisplayed = False
With Application
If .Calculation = xlCalculationManual Then
.Calculation = xlCalculationAutomatic
Else
.Calculation = xlCalculationManual
.MaxChange = 0.001
End If
End With
End Sub

Setting Calculation to automatic will automatically recalc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top