51DegreesNorth
New Member
- Joined
- Mar 29, 2022
- Messages
- 11
- Office Version
- 365
- Platform
- Windows
Hi,
I'd like to keep an eye an a certain range: if the contents of one or more of the cells in that range changes, the selection change event must call a subroutine to perform some actions.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
This code works, it selects E5 when the selection change event occurs. That's not what I want. Suppose there's a number in A3 which must be altered or deleted. Click on the cell and you end up at E5 before you had a change to edit or delete A3. The above code is on sheet level. The VBA Project contains no mudules and the workbook is otherwise completely empty.
I'm new to this whole 'events' thing ... Can you point me in the right direction please ? Is this even the correct approach for what I'm trying to do ?
Thank you !
I'd like to keep an eye an a certain range: if the contents of one or more of the cells in that range changes, the selection change event must call a subroutine to perform some actions.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
VBA Code:
If Intersect(Target, Range("A1:A6")) Is Nothing Then
Exit Sub
End If
' but if there is an overlap:
Range("E5").Select ' as an example, I'll replace it with Call Some_sub later.
End Sub
This code works, it selects E5 when the selection change event occurs. That's not what I want. Suppose there's a number in A3 which must be altered or deleted. Click on the cell and you end up at E5 before you had a change to edit or delete A3. The above code is on sheet level. The VBA Project contains no mudules and the workbook is otherwise completely empty.
I'm new to this whole 'events' thing ... Can you point me in the right direction please ? Is this even the correct approach for what I'm trying to do ?
Thank you !