Generate Every Combination of Two Columns in Excel
Question details
Create a list containing every combination of items from two columns.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Combine each item in a first list with every item in a second list.
- Observed behavior
- The desired result is one combined value per row, such as A1, A2, A3, B1, B2, and B3.
Place the first list in A1:A2 and the second list in B1:B3, or adjust the ranges in the formulas to match your data. Exclude headers and unwanted blank cells, and leave enough empty cells for the results.
Create all combinations with a dynamic array formula in Excel 365
Use one formula to generate and spill the entire list when MAKEARRAY is available.
Enter A and B in cells A1:A2, then enter 1, 2, and 3 in cells B1:B3.
Select an empty cell such as D1 and enter =MAKEARRAY(ROWS(A1:A2)*ROWS(B1:B3),1,LAMBDA(r,c,INDEX(A1:A2,ROUNDUP(r/ROWS(B1:B3),0))&INDEX(B1:B3,MOD(r-1,ROWS(B1:B3))+1))).
Press Enter. The formula spills six results down column D: A1, A2, A3, B1, B2, and B3.

Generate combinations with a fill-down formula in Excel
Use this approach when your Excel version does not support MAKEARRAY.
Generate Two-Column Combinations in WPS Spreadsheets
Use an INDEX formula in WPS Spreadsheets to combine every item in one list with every item in another, then fill the formula down to build the complete list.
- 1. Open a spreadsheet: Open WPS Spreadsheets and create a workbook or open an existing Excel file.
- 2. Enter the source lists: Enter the first list in A1:A2 and the second list in B1:B3, excluding headers.
- 3. Enter the combination formula: Select D1 and enter =INDEX($A$1:$A$2,INT((ROW(A1)-1)/ROWS($B$1:$B$3))+1)&INDEX($B$1:$B$3,MOD(ROW(A1)-1,ROWS($B$1:$B$3))+1). Adjust the list ranges if needed.
- 4. Fill the results: Drag the fill handle from D1 through D6. For different list sizes, fill down for the product of the two list lengths.

Frequently Asked Questions
How many combinations will the two lists produce?
Multiply the number of items in the first list by the number in the second. For example, two items and three items produce six combinations.
How can I add a space or hyphen between the combined values?
In either formula, replace the ampersand between the two INDEX expressions with &" "& for a space or &"-"& for a hyphen.
Why does the dynamic array formula show a spill error?
The output needs one empty cell for each combination. Clear any occupied cells in the spill area below the formula and check the result again.
Can I use the formula if my lists have headers or blank cells?
Yes, but set the formula ranges to include only the items you want to combine. Included headers and blank cells are treated as list entries.




