LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Check if a range is a sebset of another range

Jie,

You can use the Intersect method to test whether two ranges
overlap. For example,

Dim Range1 As Range
Dim Range2 As Range
Dim ISect As Range

Set Range1 = Range("A1:C3")
Set Range2 = Range("C1:C3")
Set ISect = Application.Intersect(Range1, Range2)
If ISect Is Nothing Then
MsgBox "The ranges do not overlap at all"
ElseIf ISect.Cells.Count = Range2.Cells.Count Then
MsgBox "Range2 is completely contained within Range1"
Else
MsgBox "Range2 is partially contained within Range1"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jie" wrote in message
...
Hi

Is there a method in excel object model to easily find out if a

range is a subset of another range and the start, end position of
the subset?

Thanks

Jie



 
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
range names or check box ynissel Excel Worksheet Functions 7 August 23rd 05 03:11 AM
check if value occurs within a range peacelittleone Excel Worksheet Functions 4 July 1st 05 09:46 PM
can a formula check for a certain value in a range? Lee IT Excel Discussion (Misc queries) 1 April 7th 05 04:31 PM
check range for certain value Gareth[_3_] Excel Programming 4 November 10th 03 03:08 PM
check if range containing values Markus Serbel Excel Programming 2 July 14th 03 11:26 AM


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

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

About Us

"It's about Microsoft Excel"