VBA:: 相交与匹配方法

发布于 2024-11-17 23:25:03 字数 163 浏览 4 评论 0原文

我有一个关于 .Match 和 .Intersect 两个内置 VBA 函数的问题。目前我有 2 个一维数组,我希望将它们合并到一个新数组中。我意识到我之前已经发布了一个关于解决该问题的方法的问题,但这个问题涉及哪种方法更好。一种方法是否能够比另一种方法更快地将信息整合到新数组中?一种方法比另一种方法更可靠吗?

I had a question pertaining to the two built in VBA function of .Match and .Intersect. Currently I have 2 1-dimensional arrays that I wish to consolidate information into a new array. I realize I've posted a question about the approach to the problem earlier but this question pertains to which method would be better. Would one way be able to consolidate information into a new array faster than the other? and is one method more reliable than the other as well?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

洋洋洒洒 2024-11-24 23:25:03

来自 Excel 帮助

Excel 开发人员参考

应用程序.相交方法
返回一个 Range 对象,该对象表示两个或多个范围的矩形交集。

数组不是范围,因此 interset 不适用于您所述的问题。

更详细地解释您想要做什么以及原始数据的形式将提供更好的建议

From Excel help

Excel Developer Reference

Application.Intersect Method
Returns a Range object that represents the rectangular intersection of two or more ranges.

Arrays are not ranges, so interset is not applicable to your question as stated.

A more detailed explanation of what you are trying to do, and what form your raw data is in will allow better advice

层林尽染 2024-11-24 23:25:03

如果您在 vba 中合并两个数组,则 .Match 函数和 .Intersect 的行为方式不同,因为您将无法使用Match函数合并,您将只能找到一个值。

因此,我想说,使用相交方法。

如果您想要更准确的答案,请通过示例和您已构建的代码更准确地告诉我们您想对数组执行什么操作。

问候,

麦克斯

If you are merging your two arrays in vba, then the .Match function and the .Intersect do not behave the same way because, you won't be able to merge with a Match function, you will only be able to find a value.

Hence, i would say, use intersect method.

If you want a more precise answer, please tell us more precisely what you want to do with your arrays with examples and the code you already built.

Regards,

Max

再见回来 2024-11-24 23:25:03

Intersect 是一种查找一个或多个范围的交集的方法:它不适用于数组。它返回作为范围参数的交集的子集范围。
除非您的数组已排序,否则循环比较数组可能比使用 .MATCH 更有效

Intersect is a method for finding the intersection of one or more ranges: it won't work with arrays. It returns the subset range that is the intersection of the range arguments.
Unless your arrays are sorted it would probably be more efficient to just loop compare the arrays than use .MATCH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文