Function Problems

Generate Every Combination of Two Columns in Excel

Huma Ashraf ChHuma Ashraf Ch Nov 18, 2026 868 views

Question details

Create a list containing every combination of items from two columns.

Generate Every Combination of Two Columns in Excel
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.
Before you start

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.

Solution 1Recommended

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.

1
Enter the lists

Enter A and B in cells A1:A2, then enter 1, 2, and 3 in cells B1:B3.

2
Enter the formula

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))).

3
Check the results

Press Enter. The formula spills six results down column D: A1, A2, A3, B1, B2, and B3.

Create all combinations with a dynamic array formula in Excel 365
Adjust the ranges: Replace every A1:A2 and B1:B3 reference with the corresponding list range. Clear any cells blocking the spill area.
WPS Spreadsheets

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. 1. Open a spreadsheet: Open WPS Spreadsheets and create a workbook or open an existing Excel file.
  2. 2. Enter the source lists: Enter the first list in A1:A2 and the second list in B1:B3, excluding headers.
  3. 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. 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.
Create every pair from two lists with a fill-down formulaOpen and edit Microsoft Excel XLSX and XLS filesUse familiar spreadsheet formulas and fill controlsWork with spreadsheets using the free WPS Office suite
microsoft office alternative - wps office

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.