Calculation manual / automatic

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Calculation manual / automatic

Post by VegasNath »

Is there a way of setting calculation to manual when a specific worksheet is activated, and then set to automatic upon deactivation. But preferably only applicable to manual activation / deactivation, not when vba does it?
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78630
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Calculation manual / automatic

Post by HansV »

You could use this code in the worksheet module:

Code: Select all

Private Sub Worksheet_Activate()
  Application.Calculation = xlCalculationManual
End Sub

Private Sub Worksheet_Deactivate()
  Application.Calculation = xlCalculationAutomatic
End Sub
If you want to switch to the worksheet in code, turn off event handling temporarily:

Code: Select all

  Application.EnableEvents = False
  Worksheets("MySheet").Select
  Application.EnableEvents = True
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Calculation manual / automatic

Post by VegasNath »

Cheers, :thankyou:
:wales: Nathan :uk:
There's no place like home.....