To generate random numbers without repeats in Excel, the fastest method is to use the =SORTBY(SEQUENCE(count), RANDARRAY(count)) formula. This creates a sequential list of numbers and then shuffles them randomly, ensuring every number appears exactly once. This approach is superior to basic random functions because it eliminates the risk of duplicate values and the need for manual cleanup.

What You'll Need

  • A computer with Microsoft Excel installed (Microsoft 365 or Excel 2021 or later are required for the dynamic array functions used in the primary method).
  • A basic understanding of how to enter formulas into a cell.

Step-by-Step

  1. Determine your range: Decide how many random numbers you need and the range they should cover. For example, if you need 10 unique numbers between 1 and 10, your "count" is 10.
  2. Select your starting cell: Click on the cell where you want the list of random numbers to begin.
  3. Enter the formula: Type the following formula into the cell: =SORTBY(SEQUENCE(10), RANDARRAY(10)). Replace "10" with the total number of unique values you require.
  4. Press Enter: Because this is a dynamic array formula, Excel will automatically "spill" the results downward into the cells below, filling the list instantly.
  5. Freeze the numbers (Optional): By default, RANDARRAY recalculates every time you change any cell in the workbook. To stop the numbers from changing:
    • Highlight the generated list of numbers.
    • Right-click and select Copy (or press Ctrl+C).
    • Right-click the same area again, select Paste Special, and choose Values.

Common Mistakes

  • Using RANDBETWEEN: The most common mistake is using =RANDBETWEEN(bottom, top) and dragging it down. This function picks numbers independently, meaning it is highly likely to produce duplicates.
  • Forgetting to Paste as Values: Users often forget that random functions are "volatile." If you use these numbers for a lottery or a random assignment and then enter data elsewhere in the sheet, the numbers will reshuffle unless you convert them to static values.
  • Incorrect Range Logic: Trying to pick 11 unique numbers from a range of only 10. This is mathematically impossible and will result in an error or a failure to meet the "no repeats" criteria.

Tips

  • Custom Ranges: If you need unique numbers that don't start at 1 (e.g., unique numbers between 50 and 60), modify the SEQUENCE function: =SORTBY(SEQUENCE(11, 1, 50), RANDARRAY(11)). The "11" is the count of numbers, and "50" is the starting number.
  • Horizontal Lists: If you want the numbers to go across a row instead of down a column, wrap the entire formula in the TRANSPOSE function: =TRANSPOSE(SORTBY(SEQUENCE(10), RANDARRAY(10))).
  • Randomizing Existing Lists: If you have a list of names or IDs instead of numbers, you can use =SORTBY(A1:A20, RANDARRAY(20)) to shuffle that specific list without repeats.

Troubleshooting

If the formula does not work as expected, try these steps in order:

  • Check for #NAME? Error: If you see this error, your version of Excel is likely too old to support SORTBY or RANDARRAY. These are available in Microsoft 365 and Excel 2021. If you are using an older version, you must use the "Helper Column" method: create a column of =RAND() values next to your numbers, then sort the numbers based on that random column.
  • Check for #SPILL! Error: This happens when there is already data in the cells where Excel is trying to place the random numbers. Clear the cells below and to the right of your formula cell to give the array room to expand.
  • Numbers keep changing: As mentioned in the steps, random formulas refresh on every edit. Use Copy > Paste Values to lock them in place.

Frequently Asked Questions

Can I generate unique random decimals?

Yes, but the SEQUENCE method only works for integers. For unique decimals, you can use =RANDARRAY(count, 1)` and then sort them, though decimals are statistically unlikely to repeat anyway.

How do I pick only 5 unique numbers from a range of 100?

Use the INDEX function combined with the shuffle: =INDEX(SORTBY(SEQUENCE(100), RANDARRAY(100)), SEQUENCE(5)). This shuffles 100 numbers and then only displays the first five.

Does this method work on Excel for Web?

Yes, the SORTBY, SEQUENCE, and RANDARRAY functions are fully supported in the web-based version of Microsoft Excel.

Is there a way to do this without formulas?

Yes. You can type your number range in a column, create a second column filled with =RAND(), and then use the Data > Sort tool to sort the first column based on the random values in the second.

Can I use this to randomly assign people to groups?

Yes. By generating a unique random number next to each person's name and then sorting the list, you effectively randomize the order, allowing you to assign groups based on their new position in the list.