How to list / generate all possible combinations in Excel?
Let’s say, I have the following two columns of data, and now, I want to generate a list of all possible combinations based on the two lists of values as following screenshot shown. Maybe, you can list all the combinations one by one if there are few values, but, if there are several columns with multiple values needed to be listed the possible combinations, here are some quick tricks may help you to deal with this problem in Excel.
List All Possible Combinations from multiple columns:
Kutools for Excel’s List All Combinations utility can help you quickly generate / list all possible combinations based on multiple lists of values.
Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!
The following long formula can help you to list all possible combinations of two lists values quickly, please do as follows:
1. Enter this formula: =IF(ROW()-ROW($D$1)+1>COUNTA($A$1:$A$4)*COUNTA($B$1:$B$3),"",INDEX($A$1:$A$4,INT((ROW()-ROW($D$1))/COUNTA($B$1:$B$3)+1))&INDEX($B$1:$B$3,MOD(ROW()-ROW($D$1),COUNTA($B$1:$B$3))+1)) into a blank cell, in this case, I will enter it to cell D1, and then press Enter key to get the result, see screenshot:
Note: In the above formula, $A$1:$A$4, are the first column values, and $B$1:$B$3 are the second list values which you want to list all their possible combinations, the $D$1 is the cell that you put the formula, you can change the cell references to your need.
2. Then select cell D1 and drag the fill handle down to the cells until get the blank cells, and all the possible combinations have been listed based on the two lists values. See screenshot:
The above formula can help you generate the possible combinations with only two lists, if there are more than two lists values need to be listed the possible combinations, the formula will not work. Here, I can recommend a powerful tool -- Kutools for Excel, it contains a handy feature List All Combinations which can quickly list all the possible combinations based on given data lists.
|Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.|
After installing Kutools for Excel, please do as follows:
1. Click Kutools > Insert > List All Combinations, see screenshot:
2. In the List All Combinations dialog box, do the following operations:
(1.) Choose Value from the Type drop down list;
(2.) Then click button to select the first data list that you want to use.(You can also type the values which are separated by commas into the Text box one by one )
3. Then click Add button to add the first value list into the Combinations list box, see screenshot:
4. If you need to use certain character to separate the combinations, please choose Separator from the Type drop down, and specify the separator you need in Text box, then click Add button to add the separator into the Combinations list, see screenshot:
5. Then repeat step3 and step4 to insert other data lists and separators into the Combinations list box, see screenshot:
6. After inserting the data list, then click Ok button, and a prompt box will pop out to remind you select a cell to output the result, see screenshot:
7. Click OK, all of the possible combinations based on the given lists have been generated into the worksheet as following screenshot shown:
Note: If you don’t need the separators between the combinations, you just need to skip step 4 and add the values lists into the dialog box.
Recommended Productivity Tools
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
To post as a guest, your comment is unpublished.· 2 months agoAlmost very handy. Would be good if it actually used whatever is in the cell ($A$1)and not convert the cell to text. Then I could just paste what I need in A1 and run it again without having to change anything.
To post as a guest, your comment is unpublished.· 7 months agoI used the extions and works fantastic,, but now i have a problem, i need to calculate the sum,, but the result is a text,, i enter a separator that is the simbol +, but finally i have a text and is impossible to convert in a operation.
To post as a guest, your comment is unpublished.· 7 months agoHello, and if these combinations intead text are number,, how can i made the calculation for the results???? i try to add the "+" but excel dont know that is the simbol.. how you solve this?
To post as a guest, your comment is unpublished.· 7 months agoHola me arroja una referencia circula la formula
To post as a guest, your comment is unpublished.· 1 years agoWhy my formula did not work to create 25 combinations in Column E (5 elements from Col A * 5 elements from Col B) ? Whereas the formula in this article worked in Column D when I dragged it for 25 cells? Screenshot - https://prnt.sc/ihwr18