How to Generate Unique Random Numbers from 1 to 6 in Excel
Question details
The user wants to generate a randomized array of numbers from 1 to 6 exactly once without duplicates, but is experiencing a #SPILL! error and formula syntax issues.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Creating a randomized, non-repeating sequence of numbers between 1 and 6 using a formula.
- Observed behavior
- The formula returns a #SPILL! error when the destination cells are not empty, or fails to execute properly due to extra commas in the syntax.
Ensure that the cells immediately below or adjacent to your target cell are completely empty so the generated random numbers have enough room to spill.
Use a Dynamic Array Formula (SORTBY, SEQUENCE, RANDARRAY)
Combine modern array functions to generate a sequence of numbers from 1 to 6 and randomly sort them without duplicates.
To get a unique list of randomized numbers, you can generate a sequential list first using SEQUENCE, and then scramble its order using SORTBY paired with RANDARRAY. This ensures every number from the sequence appears exactly once.
Click on the empty cell where you want the first number of your random sequence to appear.
Type the formula: =SORTBY(SEQUENCE(6), RANDARRAY(6)) into the formula bar.
Ensure there are no extra commas or missing brackets in your formula, as these will trigger an error.
Press Enter. The numbers 1 through 6 will automatically populate in a randomized order down the column.

Generate Unique Random Numbers Easily with WPS Spreadsheet
WPS Spreadsheet fully supports advanced dynamic array formulas like SEQUENCE, SORTBY, and RANDARRAY. You can easily generate randomized unique lists for games, sampling, or data testing with no complex scripting required.
- 1. Open your workbook: Launch WPS Spreadsheet and open the document where you need the random numbers.
- 2. Select your starting cell: Click on an empty cell with at least 5 empty cells directly beneath it.
- 3. Input the array formula: Type =SORTBY(SEQUENCE(6), RANDARRAY(6)) and press Enter.
- 4. View the results instantly: WPS Spreadsheet will immediately spill the 6 unique random numbers into the column.

Frequently Asked Questions
Why am I getting a #SPILL! error when generating random numbers?
A #SPILL! error occurs when an array formula tries to output multiple values into adjacent cells, but one or more of those destination cells already contain data, spaces, or formulas. Clearing the blocking cells will immediately resolve the error.
Can I generate these unique random numbers across a row instead of a column?
Yes. You can adjust the SEQUENCE function to generate columns instead of rows by specifying the column parameter. Use the formula: =SORTBY(SEQUENCE(1, 6), RANDARRAY(1, 6)) to spill the numbers horizontally across a row.
How do I change the formula to generate unique numbers from 1 to 10?
You simply need to change the numerical parameters inside the functions. Replace the '6' with '10' like this: =SORTBY(SEQUENCE(10), RANDARRAY(10)). The formula will now return a randomized, non-repeating sequence from 1 to 10.
What does the 'PopulationSize' parameter refer to in array functions?
In array formulas, PopulationSize (or the number of rows/columns specified) dictates the total number of values the function needs to produce. For generating a sequence from 1 to 6, the required population size is 6.




