All possible permutation/combinations

Dr. Demento

Well-known Member
Good morning!

Forgive me, but I don't remember the difference between permutations and combinations, so hopefully my explanation points in the proper direction.

I have two ordered lists (NORTH|SOUTH|EAST|WEST) and (N|S|E|W) and I want to make a listing of all permutations/combinations?? substituting N for NORTH, S for SOUTH, etc. The order of the values is fixed as shown.

For example, if I start with the first row, I want all possible perms/combos with both the full word and the abbreviation, as shown with the next four lines.

|-------|-------|-------|-------|
| NORTH | SOUTH | EAST | WEST |
|-------|-------|-------|-------|
| N | SOUTH | EAST | WEST |
|-------|-------|-------|-------|
| N | S | EAST | WEST |
|-------|-------|-------|-------|
| N | S | E | WEST |
|-------|-------|-------|-------|
| N | S | E | W |
|-------|-------|-------|-------|

This is just a partial example; I was trying to manually jam this out and kept getting screwed up.

Any help would be much appreciated.

Thanks y'all.

Fluff

MrExcel MVP, Moderator
VBA Code:
``````Sub DrDemento()
Dim r As Long, c As Long
Dim a As Variant, b As Variant, Ary As Variant

Ary = Array(Array("North", "East", "South", "West"), Array("N", "E", "S", "W"))
r = 2
c = 4
a = Evaluate("if({1},mid(base(transpose(row(1:" & r ^ c & ")-1)," & r & "," & c & "),row(1:" & c & "),1)+1)")
b = Application.Index(Ary, Application.Transpose(a), Array(1, 2, 3, 4))
Range("A5").Resize(UBound(b), UBound(b, 2)).Value = b
End Sub``````

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Dr. Demento

Well-known Member
Thanks so much! That's awesome!!

Fluff

MrExcel MVP, Moderator
Glad we could help & thanks for the feedback.

Replies
0
Views
72
Replies
12
Views
984
Replies
2
Views
126
Replies
3
Views
481
Replies
4
Views
300

1,181,941
Messages
5,932,898
Members
436,869
Latest member
ABGTH

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.

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