Worksheet_Selectionchange for range

  • Thread starter Thread starter tx12345
  • Start date Start date
T

tx12345

Hi

I hve this code:


Code:
--------------------
Private sub Worksheet_Selectionchange(ByVal Target As Range)

if target.address="$B$4" then
msgbox"Hello"
end if
end sub

--------------------


But I want this to work for a range of cells on the sheet, i.e.:


Code:
--------------------
Private sub Worksheet_Selectionchange(ByVal Target As Range)

if target.RANGE="A2:E4" then
msgbox "Hello"
end if
end sub



--------------------


Ideas welcome

tx
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("A2:E4")) Is Nothing Then
MsgBox "Out of Range"
Else
MsgBox "In Range"
End If
End Sub

HTH

Charles Chickering
 
Private sub Worksheet_Selectionchange(ByVal Target As Range)

if not intersect(target, Range("A2:E4")) is nothing then
msgbox"Hello"
end if
end sub
 
Private sub Worksheet_Selectionchange(ByVal Target As Range)

if not intersect(target, RANGE("A2:E4")) is nothing then
msgbox "Hello"
end if
end sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Back
Top