views:

12

answers:

1

In the Excel Interop libraries, is there functionality to determine whether a given Range object is contained within another Range object?

It would be simple enough for me to compare the row and column indices of each Range, but things become more complicated when you want to compare two ranges that may be on different worksheets.

+1  A: 

Application.Intersect will do the job.

It will give you a Range that is the intersection of two ranges A and B

If Range A is contained in Range B, then the result will have the same width and height as A.

The result will be null / Nothing if the ranges don't intersect at all.

Joe