Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Check if a range is inside another

Hi,

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


Rafael


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Check if a range is inside another

Hi Rafael
This will give you a start
;-)

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("myrng")) Is Nothing Then
MsgBox "ranges intersect"
Else
MsgBox "Ranges Don't intersect!"
End If
End Sub


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




  #3   Report Post  
Posted to microsoft.public.excel.programming
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i use countif function inside a filtered range jayin New Users to Excel 1 February 24th 09 07:05 AM
how can I check for cell focus inside a spreadsheet ? EdwardAlanzo Excel Worksheet Functions 2 May 16th 07 12:41 AM
Using a range variable inside a excel function Michael Excel Discussion (Misc queries) 2 November 14th 05 02:52 PM
Check if a String is inside an Array Dave Peterson[_3_] Excel Programming 3 September 3rd 03 08:41 PM
Check if a String is inside an Array Alan Beban[_3_] Excel Programming 0 September 3rd 03 07:44 PM


All times are GMT +1. The time now is 10:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"