Tip: Other languages are Google-Translated. You can go to the English version of this link.
Log in


How to generate random number without duplicates in Excel?

In many cases, you may want to generate random numbers in Excel? But with the general formulas to randomize numbers, there may be some duplicate values. Here I will tell you some tricks to generate random numbers without duplicates in Excel.

Generate unique random numbers with formulas

Generate unique random number with Kutools for Excel’s Insert Random Data (Easy!) good idea3

Insert Random Data

excel addin tool for generate random integers dates times strings custom lits

arrow blue right bubble Generate unique random numbers with formulas

To generate the unique random numbers in Excel, you need to use two formulas.

1. Suppose you need to generate random numbers without duplicates into column A and column B, now select cell E1, and type this formula =RAND(), then press Enter key, see screenshot:

2. And select the whole column E by pressing Ctrl + Space keys simultaneously, and then press Ctrl + D keys to apply the formula =RAND() to the whole column E. See screenshot:

3. Then in the cell D1, type the maximum number of your needed random number. In here case, I want to insert random numbers without repeated between 1 and 50, so I will type 50 into D1.

4. Now go to Column A, select cell A1, type this formula =IF(ROW()-ROW(A$1)+1>$D$1/2,"",RANK(OFFSET($E$1,ROW()-ROW(A$1)+(COLUMN()-COLUMN($A1))*($D$1/2),),$E$1:INDEX($E$1:$E$1000,$D$1))), then drag the fill handle to next column B, and drag down the fill handle to the range you need. See screenshot:

Now, in this range, the random numbers you need are no repeated.


1. In the above long formula, A1 indicates the cell you use the long formula, D1 indicates the maximum number of the random number, E1 is the first cell of column you apply formula =RAND(), and 2 indicates you want to insert random number into two columns. You can change them as your need.

2. When all the unique numbers are generated into the range, the redundant cells will be shown as blank.

3. With this method, you just can generate random number start from number 1. But with the second way, you can easily specify the random number range.

arrow blue right bubble Generate unique random number with Kutools for Excel’s Insert Random Data

With above formulas, there are too much inconvenience to handle. But with Kutools for Excel’s Insert Random Data feature, you can quickly and easily to insert the unique random numbers as your need which will saves a lot of time.

Kutools for Excel, with more than 120 handy functions, makes your jobs easier. 

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

1. Select the range you need to generate random numbers, and click Kutools > Insert > Insert Random Data. See screenshot:
doc radomize positive negative 11

2. In the Insert Random Data dialog, go to the Integer tab, type the number range you need into the From and To text boxes, and remember to check Unique values option. See screenshot:
doc randomize unique 2

3. Click Ok to generate the random numbers and exit the dialog.
doc randomize unique 3

Note:If your selected cells are more than the random numbers, the redundant cells are displayed as blank.

You also can insert the random unique date, random unique time by Insert Random Data. If you want to have a free trial of Insert Random Data, please downloan it right now!

doc randomize unique 4doc randomize unique 5

Tip.If you want to select or sort data randomly, please try to use the Kutools for Excel’s Sort Range Randomly as shown in the following screenshot. It’s full function without limitation in 60 days, please download and have a free trial now.

doc select randomly

arrow blue right bubble Insert Random Data Without Duplicate

Recommended Productivity Tools

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 200 New Features for Excel, Make Excel Much Easy and Powerful:

  • Merge Cell/Rows/Columns without Losing Data.
  • Combine and Consolidate Multiple Sheets and Workbooks.
  • Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
  • Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
  • More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...

Screen shot of Kutools for Excel

btn read more      btn download     btn purchase

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    JIGGLY BALLS · 1 years ago
    After about three hours of trying to completely understand the long complicated formula to generate random numbers without duplicates, I figured out a far simpler formula that has the same results. After you randomly generate the numbers in a column using the RAND() function, You can simplify the formula:=IF(ROW()-ROW(A$1)+1>$D$1/2,"",RANK(OFFSET($E$1,ROW()-ROW(A$1)+(COLUMN()-COLUMN($A1))*($D$1/2),),$E$1:INDEX($E$1:$E$1000,$D$1))) in cell a1 to =Rank(E1,$E$1:$E$50). Then if you would like 50 random generated "unique numbers." you simply drag the formula through column a to cell a50. It is a lot simpler. Thank you for answering my question regardless of the huge unneeded formula. If you did not have this website. I don't think I would have been able to solve my problem.

  • To post as a guest, your comment is unpublished.
    Bernz · 1 years ago
    Hi, Base on [b]Generate unique random numbers with formulas [/b], How can I specify the starting point of a random number? Let's say I want to random "15 to 30".
    • To post as a guest, your comment is unpublished.
      RK Mohanty · 6 months ago
      Use RANDBETWEEN() to get random numbers lies between two numbers.