My first plan was to repeat this for every named range, until i realized how much that would be.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(ActiveCell, Range("M_1")) Is Nothing Then
Else
Range("M_1").Select
End If
End Sub
Add a loop to iterate through the named ranges:
First you'll want to change that
activecell
totarget
sincetarget
is static as the calling range. Also, just add aNOT
condition to yourIF
so you don't have to use theELSE
If you wanting to test
target
against a list of named ranges to see iftarget
intersects at least one of the named ranges, you can use the application'sunion
method:You could also do a loop if you need more control: