ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Toggle AutoCalc (https://www.excelbanter.com/excel-programming/340063-toggle-autocalc.html)

Sandy

Toggle AutoCalc
 
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!

JE McGimpsey

Toggle AutoCalc
 
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.

In article ,
"Sandy" wrote:

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!


Sandy

Toggle AutoCalc
 
Thank you!

"JE McGimpsey" wrote:

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.

In article ,
"Sandy" wrote:

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!




All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com