Comparing Ranges in Excel
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 indic开发者_如何学Pythones of each Range
, but things become more complicated when you want to compare two ranges that may be on different worksheets.
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.
精彩评论