tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
My workbook contains Sheet1 and Sheet2.
The code in Sheet1 is as follows:
and in Sheet2:
I am trying to prevent users moving away from Sheet2.
When I'm on Sheet2, I click on Sheet1 and the Worksheet_Deactivate kicks off.
When Me.Activate is run, Sheet2 is active.
After Application.EnableEvents = True is run, Sub Worksheet_Activate on Sheet1 gets trigged.
How can I prevent Worksheet_Activate from running?
Thanks
The code in Sheet1 is as follows:
Code:
Option Explicit
Private Sub Worksheet_Activate()
MsgBox "hi"
End Sub
and in Sheet2:
Code:
Option Explicit
Private Sub Worksheet_Deactivate()
Application.EnableEvents = False
Me.Activate
Application.EnableEvents = True
End Sub
I am trying to prevent users moving away from Sheet2.
When I'm on Sheet2, I click on Sheet1 and the Worksheet_Deactivate kicks off.
When Me.Activate is run, Sheet2 is active.
After Application.EnableEvents = True is run, Sub Worksheet_Activate on Sheet1 gets trigged.
How can I prevent Worksheet_Activate from running?
Thanks