Generate All Five-Number Combinations from 1 to 35 in Excel
Question details
Generate every ascending combination of five distinct numbers chosen from 1 through 35, with each number in a separate column.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Create a complete list of five-number combinations in a spreadsheet.
- Observed behavior
- The desired result is 324,632 unique rows, each containing five ascending numbers.
Open a blank worksheet with at least 324,633 rows and five available columns. Generating and filling more than 1.6 million cells may take time.
Generate the combinations with worksheet formulas
Use five formulas to generate the full list without enabling macros.
Each row calculates the next ascending combination from the row above. With headers in row 1, the final combination appears in row 324633.
In a blank worksheet, enter headers in A1:E1 if desired. Enter 1, 2, 3, 4, and 5 in cells A2 through E2, respectively.
Enter these formulas in row 3: A3: =IF(B2=32,A2+1,A2); B3: =IF(C2=33,IF(B2=32,A3+1,B2+1),B2); C3: =IF(D2=34,IF(C2=33,B3+1,C2+1),C2); D3: =IF(E2=35,IF(D2=34,C3+1,D2+1),D2); E3: =IF(E2=35,D3+1,E2+1).
Enter A3:E324633 in the Name Box beside the formula bar, then choose Home > Fill > Down. Wait for Excel to finish calculating.
Use the Name Box to go to A324633:E324633. The final row should contain 31, 32, 33, 34, and 35.

Generate the combinations with an Excel VBA macro
Use a macro to write the combinations as values instead of worksheet formulas.
Create the combination list in WPS Spreadsheets
Use familiar worksheet formulas in WPS Spreadsheets to generate the same ascending combinations, with one number in each column.
- 1. Open a blank sheet: Open WPS Spreadsheets and create a blank workbook. Enter 1, 2, 3, 4, and 5 in A2:E2.
- 2. Enter the formulas: Enter the five formulas from the worksheet-formula solution in cells A3:E3.
- 3. Fill the list: Use the Name Box to select A3:E324633, then choose Home > Fill > Down and wait for the calculation to finish.
- 4. Check and save: Check that A324633:E324633 contains 31, 32, 33, 34, and 35, then choose File > Save As to save the workbook.

Frequently Asked Questions
How many five-number combinations can be made from 1 to 35?
There are 324,632 combinations: 35 choose 5. Each combination contains distinct numbers, and order does not create a separate combination.
Will the list fit on one Excel worksheet?
Yes. The list needs 324,632 rows, or 324,633 rows with a header, which fits within the 1,048,576-row limit of modern Excel worksheets.
Do I need to enable macros to generate the list?
No. Enter the formulas in A3:E3 and use Home > Fill > Down through row 324633. Enable macros only if you choose the VBA method.
How can I check that the list is complete?
Check that A2:E2 contains 1, 2, 3, 4, 5 and that A324633:E324633 contains 31, 32, 33, 34, 35. The rows between them should contain ascending, distinct numbers.




