AD_Taylor
Well-known Member
- Joined
- May 19, 2011
- Messages
- 687
Hi,
Has anybody got a VBA Macro that will take a number of items and combine them in various different ways and show all possible combinations?
For example, if I put 4 numbers, (1 into each A1, B1, C1 and D1) the macro should figure out all the possible ways of combining those numbers in a different order. Lets say:
A1 = 1
B1 = 2
C1 = 3
D1 = 4
Then the output would be something like
1234
1243
1324
1342
1423
1432
2134
2143
etc. until all possible solutions are found.
It would be great if the macro could output the combinations in line with the columns the items were in and then have a separate concatentation column that combines them at the end.
Also it should be able to work for any number of items specified (For my purposes I'll only be going up to about 10 max).
I should probably point out that the 'items' being combined can be strings or numbers (should always be integers).
Oh and if it could show the number of combinations found in a separate cell that would be perfect
Appreciate any help with this I know its a big ask to have somebody produce this for me!
~Adam
Has anybody got a VBA Macro that will take a number of items and combine them in various different ways and show all possible combinations?
For example, if I put 4 numbers, (1 into each A1, B1, C1 and D1) the macro should figure out all the possible ways of combining those numbers in a different order. Lets say:
A1 = 1
B1 = 2
C1 = 3
D1 = 4
Then the output would be something like
1234
1243
1324
1342
1423
1432
2134
2143
etc. until all possible solutions are found.
It would be great if the macro could output the combinations in line with the columns the items were in and then have a separate concatentation column that combines them at the end.
Also it should be able to work for any number of items specified (For my purposes I'll only be going up to about 10 max).
I should probably point out that the 'items' being combined can be strings or numbers (should always be integers).
Oh and if it could show the number of combinations found in a separate cell that would be perfect
Appreciate any help with this I know its a big ask to have somebody produce this for me!
~Adam