View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Check if a range is inside another

Loomah showed how to check if they intersect by at least one cell although I
would assume contain means that all cells in target are within the range of
myrng . To see if target is totally contained in the range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.Union(Target, Range("myrng")).Address =
Range("myrng").Address Then
MsgBox "Target is contained within or equal to myrng"
Else
MsgBox "Target not contained within or equal to myrng"
End If
End Sub

you can use Intersect and compare the address to Target.address

--
Regards,
Tom Ogilvy


"Rafael Sobral" wrote in message
...
Hi,

What options do I have to check if the target range of a
SelectionChange event is inside another?


Rafael