View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
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