kylefoley76
Well-known Member
- Joined
- Mar 1, 2010
- Messages
- 1,553
Let's say I have two arrays with 4 of the same members. The members are A B C E. Now let's say I want to loop through both arrays to see if there is a match. To do that I had to do the following:
For i = 1 to ubound(1st_array)
For j = 1 to ubound(2nd_array)
if 1st_array(i) = 2nd_array(j) then
goto Z
end if
next
next
Now if there is no match, it seems that Excel will redundantly check certain combinations twice. For example, we only need check the following combinations
AB
AC
AD
AE
BC
BD
BE
CD
CE
But given the way that the function is set up, Excel will check some members more than once. It will also check
BA
CB
CA
DA
DB
DC
And it need not check those. This is not a big problem when we are dealing with arrays of 4 members but it is a problem when we are dealing with an array of 20 members. How do I get around this problem?
For i = 1 to ubound(1st_array)
For j = 1 to ubound(2nd_array)
if 1st_array(i) = 2nd_array(j) then
goto Z
end if
next
next
Now if there is no match, it seems that Excel will redundantly check certain combinations twice. For example, we only need check the following combinations
AB
AC
AD
AE
BC
BD
BE
CD
CE
But given the way that the function is set up, Excel will check some members more than once. It will also check
BA
CB
CA
DA
DB
DC
And it need not check those. This is not a big problem when we are dealing with arrays of 4 members but it is a problem when we are dealing with an array of 20 members. How do I get around this problem?