![]() |
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 |
All times are GMT +1. The time now is 09:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com