To generate random numbers without duplicates in Excel, the most efficient method is to use the =SORTBY(SEQUENCE(count), RANDARRAY(count)) formula in modern Excel versions, or the helper column method in older versions. This ensures that every number in your specified range is used exactly once, preventing the repetition that occurs when using the standard RANDBETWEEN function.
What You'll Need
- A computer with Microsoft Excel installed (Office 365, Excel 2021, or older versions like 2016/2019).
- A basic understanding of how to enter formulas into a cell.
- A defined range of numbers (e.g., numbers 1 through 50) that you wish to randomize.
Step-by-Step
Depending on your version of Excel, you will use one of two primary methods. The first is for users with Dynamic Array support (Office 365 and Excel 2021+), and the second is a universal method that works in every version of Excel ever released.
Method 1: Using Dynamic Array Formulas (Modern Excel)
- Determine your range: Decide how many unique numbers you need. For example, if you want a random list of numbers from 1 to 100, your count is 100.
- Select a starting cell: Click on the cell where you want the list to begin.
- Enter the formula: Type the following formula:
=SORTBY(SEQUENCE(100), RANDARRAY(100)). Replace "100" with whatever your total count is. - Press Enter: Because this is a dynamic array formula, Excel will automatically "spill" the results down the column. You will instantly see a list of 100 unique numbers in a completely random order.
- Freeze the values (Optional): These numbers will recalculate every time you change any cell in the workbook. To stop this, select the generated list, copy it (Ctrl+C), right-click the same area, and choose Paste Values.
Method 2: The Helper Column Method (All Excel Versions)
If you are using an older version of Excel that does not support SEQUENCE or RANDARRAY, you must use a helper column to force uniqueness.
- Create your sequence: In column A, type "1" in cell A1 and "2" in cell A2. Highlight both cells and drag the fill handle (the small green square at the bottom right) down until you reach your desired maximum number (e.g., 100). You now have a static list of unique numbers.
- Create the random helper: In cell B1, enter the formula
=RAND(). This generates a random decimal between 0 and 1. - Fill the helper column: Double-click the fill handle of cell B1 to send the
=RAND()formula down to the bottom of your list. Every number in column A now has a corresponding random decimal in column B. - Sort by the random column: Select all the data in both columns A and B. Go to the Data tab on the top ribbon and click the Sort button.
- Configure the sort: In the Sort dialog box, ensure "Sort by" is set to Column B (the column containing the
=RAND()formulas). Leave the order as "Smallest to Largest" or "Largest to Smallest"—it doesn't matter. Click OK. - Clean up: Your numbers in Column A are now in a random order with zero duplicates. You can now delete Column B.
Method 3: Randomizing a Specific Set of Non-Sequential Values
Sometimes you don't need 1-100, but rather a random selection from a specific list (e.g., a list of employee names or specific ID numbers).
- List your items: Enter your specific list of items or numbers in Column A.
- Add the randomizer: In Column B, enter
=RAND()and drag it down to match your list. - Sort the list: Select both columns, go to Data > Sort, and sort by Column B.
- Extract your sample: If you only needed 5 random items from a list of 50, simply take the first 5 rows after the sort.
Common Mistakes
The most frequent error users make is using =RANDBETWEEN(1, 100) and dragging it down 100 times. While this generates random numbers, it does not prevent duplicates. Because each cell calculates independently, it is statistically likely that some numbers will appear twice while others are omitted entirely.
Another common mistake is forgetting to "Paste Values" after using the RANDARRAY or RAND() functions. These functions are volatile, meaning they recalculate every time you press Enter, delete a row, or save the file. If you are using these numbers for a lottery, a prize draw, or a scientific sample, a changing list can lead to data integrity issues or disputes.
Users also often forget to select both the sequence column and the random column before sorting. If you only select the random column and sort it, the random numbers will move but the sequence numbers will stay put, resulting in no actual randomization of your data.
Tips
To make your randomizer more flexible, use cell references instead of hard-coding numbers. Instead of =SEQUENCE(100), put the number 100 in cell D1 and use =SEQUENCE(D1). This allows you to change the size of your random list instantly without editing the formula.
If you need to generate random numbers across multiple columns rather than one long list, you can wrap your SORTBY formula in a WRAPROWS function. For example, =WRAPROWS(SORTBY(SEQUENCE(100), RANDARRAY(100)), 10) will create a 10x10 grid of unique random numbers.
For those who need to perform this task frequently, consider turning your data range into an official Excel Table (Ctrl+T). When you add new items to a table, formulas in the adjacent columns (like the =RAND() helper) will automatically copy down to the new rows, saving you from manual dragging.
Troubleshooting
The formula returns a #NAME? error: This happens if you are using an older version of Excel (like 2016 or 2019) that does not recognize SORTBY, SEQUENCE, or RANDARRAY. These functions are only available in Microsoft 365 and Excel 2021. If you see this error, switch to the Helper Column Method described above.
The formula returns a #SPILL! error: This occurs when there is already data in the cells where the dynamic array is trying to place the results. For example, if you put the SORTBY formula in cell A1 for 100 numbers, but you have a stray piece of text in cell A50, Excel cannot "spill" the results. Clear all cells below and to the right of your formula cell to fix this.
The numbers keep changing: As mentioned, RAND functions are volatile. To stop the numbers from changing, select the range, press Ctrl+C, right-click, and select the icon with "123" (Paste Values). This converts the formulas into static numbers.
The sort didn't seem to work: Ensure that you didn't have any merged cells in your range. Excel often struggles to sort ranges that contain merged cells. Unmerge all cells in the target area and try the sort again.
Frequently Asked Questions
Can I generate random numbers without duplicates using only one cell?
Yes, in modern Excel, you can use a single cell to generate a whole list using the =SORTBY(SEQUENCE(n), RANDARRAY(n)) formula. The results will automatically spill into the cells below.
Is there a way to do this without using a helper column in old Excel?
Not easily. Older versions of Excel lack the array-handling capabilities to ensure uniqueness within a single formula. The helper column is the most reliable and fastest method for those versions.
How do I generate random numbers between two specific numbers (e.g., 500 and 600)?
Use the formula =SORTBY(SEQUENCE(101, 1, 500), RANDARRAY(101)). The SEQUENCE function allows you to specify the start value (500) and the number of steps (101 to reach 600).
Does this method work for randomizing names or text?
Yes. The Helper Column Method works for any data type. Simply list your names in Column A, put =RAND() in Column B, and sort by Column B.
Why is RANDBETWEEN not suitable for this?
RANDBETWEEN picks a number independently for every cell. It does not "remember" what it picked for the previous cell, meaning it can and will pick the same number multiple times.
Can I use this to pick a random winner from a list?
Yes. The most transparent way is to use the Helper Column Method, sort the list, and then pick the person at the very top of the list.