I want to suspend calculations when a certain worksheet is activated and then reset calculation to whatever it was originally set to when the sheet is deactivated. It works fine if I only have one view open. But if I have two (or more) Windows open in the same workbook (View/New Window), the Worksheet_Activate and Worksheet_Deactivate events do not trigger when you move between views, so calculations remain set to manual when the user moves to the alternate view. I did notice the Workbook_WindowActivate and Workbook_WindowDeactivate events, but can't quite make that work either. The code below is in the worksheet module. I need a "Worksheet_GotFocus" event, or for the Worksheet_Activate event to trigger when the View is activated. Or perhaps I can hang the code off the Selection_Change event so that as soon as the user clicks within the sheet in question, iot triggers the code, but not sure how to handle the deactivation in that case. Any ideas anyone?
Option Explicit
Dim vCalc As Variant
Private Sub Worksheet_Activate()
'save auto calc setting - suspend auto calcs
vCalc = Application.Calculation
If Application.Calculation <> xlCalculationManual Then _
Application.Calculation = xlCalculationManual
End Sub
Private Sub Worksheet_Deactivate()
'force calculation of UDF's (leave related)
If Range("rfRLeaveChanged") = "X" Then
'blah blah blah
End If
'reset auto calc (if applicable)
If Application.Calculation <> vCalc Then _
Application.Calculation = vCalc
End Sub