开发者

Comparing Ranges in Excel

开发者 https://www.devze.com 2023-01-01 18:59 出处:网络
In the Excel Interop libraries, is there functionality to determine whether a given Range object is contained within another Range object?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消