Hi guys,
I want to have some code that activates when particular cells are selected within a dynamic range that Selectionchange can set.
The range in which I want this code to run will change over time. I want my selectionchange to be able to find the bottom of a table (A4) and then have this code only run within the table and within columns B and C.
Ie, not the whole of columns B and C, as I want to be able to have other things below this table that will not be affected).
See code below.
Thanks
Jimmy
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count = 0 Then Exit Sub
Application.ScreenUpdating = False
Dim X1 As Range
Dim X2 As Range
Dim AAA As Long
Set X1 = Range("A4")
X1.Select
Selection.End(xlDown).Select
Set X2 = Selection
For i = 1 To 5
Do While Not IsEmpty(X2.Offset(i, 0))
Selection.End(xlDown).Select
Set X2 = Selection
i = 1
Loop
Next i
If Intersect(Target, Range(X1.Offset(0, 2), X2.Offset(0, 2))) Is Nothing Then
Else
AAA = Target.Value
End If
End Sub
Bookmarks