tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
My workbook contains two worksheets, Sheet1 and Sheet2.
Sheet2 contains a Worksheet_Activate event.
Sheet1 contains a Worksheet_Deactivate event.
If the active sheet is Sheet1 and the user attempts to navigate to Sheet2, the Worksheet_Deactivate events kicks off.
If a certain condition is not met, I want the user to remain on Sheet1.
What I have found is even if I disable events, like:
the moment events are enabled, the Worksheet_Activate event on Sheet2 is kicked off.
How can I prevent that?
I suppose I could set up a global variable, such that if the condition is not met, this global variable is set to false and then in Sheet2, add this:
Thanks
Sheet2 contains a Worksheet_Activate event.
Sheet1 contains a Worksheet_Deactivate event.
If the active sheet is Sheet1 and the user attempts to navigate to Sheet2, the Worksheet_Deactivate events kicks off.
If a certain condition is not met, I want the user to remain on Sheet1.
What I have found is even if I disable events, like:
Code:
Application.EnableEvents = False
Me.Activate
Application.EnableEvents = True
the moment events are enabled, the Worksheet_Activate event on Sheet2 is kicked off.
How can I prevent that?
I suppose I could set up a global variable, such that if the condition is not met, this global variable is set to false and then in Sheet2, add this:
Code:
Private Sub Worksheet_Activate()
If GlobalVar = True then
' some code
End If
End Sub
Thanks
Last edited: