# Inner and outer loops

#### kylefoley76

##### Well-known Member
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
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?

### Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

#### Danerida

##### Board Regular
With arrays, those combinations are all treated as unique, even though they are made up of the same combinations of letters. Because the order of the letters is different, they are unique to the others.

Replies
1
Views
682
Replies
0
Views
206
Replies
3
Views
459
Replies
0
Views
199
Replies
6
Views
726

1,195,704
Messages
6,011,206
Members
441,594
Latest member
AVO

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back