Displaying all combinations of a range of numbers

G

Guest

How do I display all the combinations of a group of numbers

Example
Cell A1='3'
Cells B1='1', B2=3, B3=9, B4=20, B5=25

This will display all the combinations of 3(A1) numbers from the numbers
1,3,9,20,25

1 3 9
1 3 20
1 3 25 etc

The amount in cell A1 will change as well as the total of numbers in the
range.
 
G

Guest

If i didn't make it clear enough. Hope this helps.

Simply, in my example above, display all the combinations of the number in
cell A1 in a range. So the above would be

A1='2' A1='3' A1='4'
1 3 1 3 9 1 3 9 20
1 9 1 3 20 1 3 9 25
1 20 1 3 25 3 9 20 25
1 25 1 9 20 9 20 25 1
3 9 1 9 25 9 20 25 3
3 20 3 9 20 20 25 1 3
3 25 3 9 25 etc
9 20 9 20 25
9 25 20 25 1
20 25 20 25 3
etc etc

Again, the numbers in cells be can be different and there is no maximum.
Also the combinations shouldnt repeat the same combinations i.e. 1 3 and 3 1.

I hope this I hope this is clearer.

Thanks
 
M

Myrna Larson

You need a macro for this. I've written the code. You can find it on Google if
you search for

combinations permutations

posted by Myrna Larson in groups microsoft.public.excel.*

But it will not work with your layout. It requires a column of data, with the
top cell containing "C" or "P" (for combinations or permutations), the number
in a set in the cell below that (what you say you have in A1), and the members
of the population in the cells below that (what you say you have in B1:B5).
i.e. you would need "C" in A1, the number 3 in A2, and the numbers 1, 3, 9,
20, and 25 in A3:A7
 
M

Myrna Larson

PS: The code is not locked, so you could perhaps modify it to fit your layout
if you can't modify the layout.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top