gpt4 book ai didi

Excel 的 VBA - 如何检查范围的交集不为空

转载 作者:行者123 更新时间:2023-12-03 00:50:16 25 4
gpt4 key购买 nike

我有两个问题:1)如何检查交集或范围是否不为空?例如,如果我想检查它是否为空,我会这样写

if application.intersect(r1,r2) is nothing

但是有什么东西是否定虚无的吗?例如,并不是没有什么不起作用。

2) 如何比较范围?例如,我有范围 r1,r2,r3,我想检查 r1 和 r2 的交集是否为 r3。我尝试过但没有成功的两件事:

1 - application.intersect(r1,r2) = r3
2 - application.intersect(r1,r2) is r3

非常感谢我能得到的任何帮助,谢谢!

最佳答案

查看两个范围的交集是否是第三个范围:

Set intRng =  Intersect(R1, R2)
If Not intRng Is Nothing then
Set intRng = Intersect(intRng, R3)
If Not Intersect(intRng) Is Nothing
If intRng.Address = R3.Address Then MsgBox "intersection of ranges R1 and R2 is range R3"
End If
End If

关于Excel 的 VBA - 如何检查范围的交集不为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42819244/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com