VBA:: intersect vs. match method
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 reliabl开发者_StackOverflow社区e than the other as well?
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
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
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
精彩评论