tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
Further to my thread here:
Here is the code:
I have finally found what the problem is.
In Sheet1, if you changed the cells A1, B1, C1 or D1, the Worksheet_Change event kicks in as expected.
When it runs to the End Sub, The Worksheet_SelectionChange event gets triggered (which I don't understand but that's beside the point).
However, if some of the cells, say A1 and B1 contains data validation, then changing their values will again kick off the Worksheet_Change event but this time, when it runs to the End Sub, the Worksheet_SelectionChange event will NOT kick in.
Rich (BB code):
Here is the code:
Rich (BB code):
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
With Application
.EnableEvents = False
Select Case Target.Column
Case 1
Me.Cells(Target.Row, 2).Select
Case 2
Me.Cells(Target.Row, 3).Select
Case 3
Me.Cells(Target.Row, 4).Select
Case 4
Me.Cells(Target.Row, 1).Select
End Select
.EnableEvents = True
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MsgBox "Bug!"
End Sub
I have finally found what the problem is.
In Sheet1, if you changed the cells A1, B1, C1 or D1, the Worksheet_Change event kicks in as expected.
When it runs to the End Sub, The Worksheet_SelectionChange event gets triggered (which I don't understand but that's beside the point).
However, if some of the cells, say A1 and B1 contains data validation, then changing their values will again kick off the Worksheet_Change event but this time, when it runs to the End Sub, the Worksheet_SelectionChange event will NOT kick in.