• Status: Solved
• Priority: Medium
• Security: Public
• Views: 226

# formula to produce all combinations of values in a column

In column A I have values from row 1 to row 60.  I need a formula to generate all of the combinations of the values in column A, which can be written in cell B1 and then copies down column B.

Example:

A1 = 1
A2 = 2
A3 = 3
A4 = 4

So,

B1 = A1+A1 = 2
B2 = A1+A2 = 3
B3 = A1+A3 = 4
B4 = A1+A4 = 5
B5 = A2+A2 = 4
B6 = A2+A3 = 5
B7 = A2+A4 = 6
B8 = A3+A3 = 6
B9 = A3+A4 = 7
B10 = A4+A4 = 8

I need a formula I can enter in cell B1 and copy down the column until all combinations have been computed.

Thanks.
0
pwflexner
1 Solution

Author Commented:
I'm not sure how tough this question is, and thus how many points to assign it...
0

Data EngineerCommented:
What about the formula from B11 onwards?do you want to repeat the same pattern?
0

Microsoft MVP ExcelCommented:
Hello,

this would be much easier with a matrix instead of a formula in a column.

With values in A1 to A60, copy these values to another sheet, starting with the first value in A2, not A1. Paste the same clipboard content of the 60 cells into cells B1 to BI1 with the Paste Special > Transpose option.

Then you can use a formula like this in cell B2

=\$A2+B\$1

copy down and across. You will have a matrix with 3600 cells.

cheers, teylyn
0

IT DirectorCommented:
Try the attached file, I created a macro that will build the formulas for you.
Create-Formulas.xlsm
0

Author Commented:
Thanks to all, but peetjh's solution worked best for me.  Very elegant!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.