VBA & Macro Problems

Generate All Five-Number Combinations from 1 to 35 in Excel

John WilsonJohn Wilson Nov 18, 2026 869 views

Question details

Generate every ascending combination of five distinct numbers chosen from 1 through 35, with each number in a separate column.

Generate All Five-Number Combinations from 1 to 35 in Excel
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.
Before you start

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.

Solution 1Recommended

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.

1
Enter the first combination

In a blank worksheet, enter headers in A1:E1 if desired. Enter 1, 2, 3, 4, and 5 in cells A2 through E2, respectively.

2
Enter the formulas

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

3
Fill down

Enter A3:E324633 in the Name Box beside the formula bar, then choose Home > Fill > Down. Wait for Excel to finish calculating.

4
Check the last row

Use the Name Box to go to A324633:E324633. The final row should contain 31, 32, 33, 34, and 35.

Generate the combinations with worksheet formulas
Stop at the specified row: Do not fill beyond row 324633: the formulas are designed to produce the requested combinations only through the final row.
Generate combinations without macros

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. 1. Open a blank sheet: Open WPS Spreadsheets and create a blank workbook. Enter 1, 2, 3, 4, and 5 in A2:E2.
  2. 2. Enter the formulas: Enter the five formulas from the worksheet-formula solution in cells A3:E3.
  3. 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. 4. Check and save: Check that A324633:E324633 contains 31, 32, 33, 34, and 35, then choose File > Save As to save the workbook.
Generate all 324,632 combinations without enabling macrosOpen and save Microsoft Excel XLSX workbooksUse a familiar spreadsheet interfaceWork with a free Office suite
QA img-9

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.