Skip to main content
 

How to insert random (integer) numbers between two numbers without repeats in Excel?

Author: Kelly Last Modified: 2024-08-12

Do you need to insert random numbers in Microsoft Excel? There are several methods to insert random numbers in a range as follows:

Insert random numbers by formulas

Insert random numbers with specified decimal places by VBA

Insert random integer numbers/dates/times without repeats/duplicates


Insert random numbers between two numbers with RAND function and RANDBETWEEN formulas

This method will apply the RAND function and RANDBETWEEN function to insert random numbers between two numbers into a specified range in Excel. Please view below formulas:

Formula Description (Result)
=RAND() A random number between 0 and 1 (varies)
=RAND()*100 A random number between 0 and 100 (varies)
=RANDBETWEEN(low, high) A random integral number between two given integer numbers, such as RANDBETWEEN(50, 100).

See below screenshots:

Random numbers between 0 and 1
=RAND()
random numbers between 0 and 1
Random numbers between 0 and 100
=RAND()*100
random numbers between 0 and 100
Random integer numbers between 50 and 100
=RANDBETWEEN(50, 100)
random integer numbers between 50 and 100


Insert random numbers between two numbers with specified decimal places by VBA

Below VBA can help you insert any random integer numbers or random numbers with given decimal places into a specified range in Excel. Please do as follows:

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module window.

Public Function RandomNumbers(Num1 As Long, Num2 As Long, Optional Decimals As Integer)
'Update20131113
Application.Volatile
Randomize
If IsMissing(Decimals) Or Decimals = 0 Then
    RandomNumbers = Int((Num2 + 1 - Num1) * Rnd + Num1)
Else
    RandomNumbers = Round((Num2 - Num1) * Rnd + Num1, Decimals)
End If
End Function

3. Save and close the code, then in a blank cell, input this formula =RandomNumbers(X,Y,Z), X indicates the lower limit of the numbers, Y indicates the higher limit of the numbers, and Z is the specified decimal places of random numbers.

For example, I want to generate some whole numbers between 50 and 1000, I can insert this formula =randomnumbers (50,1000,0); and insert random numbers between 50 and 100 with 2 decimal places with this formula =randomnumbers (50,100,2). See below screenshots:

Insert Random numbers without decimal places:
random integer numbers between 50 and 100
Insert Random numbers with 2 decimal places:
random numbers between 50 and 500 with 2 decimal places

Insert random whole numbers / dates / time without duplicates by Kutools for Excel

Kutools for Excel's Insert Random Data makes it possible to insert random integral numbers between two numbers without duplicates into selected range in Excel. Please do as follows:

Kutools for Excel - Packed with over 300 essential tools for Excel. Enjoy permanently free AI features! Download now!

1. Select the range you want to insert random integer numbers, and click Kutools > Insert > Insert Random Data, see screenshot:
go to Insert Random Data of kutools

2. In the Insert Random Data dialog box, (1) click Integer tab, (2) In the From and To boxes type the number range you will generate random whole numbers between, (3) check the Unique Values option, (4) and click the Ok button. See screenshot:
set options in the Insert Random Data dialog box and get the random numbers

This fantastic Insert Random Data feature also supports to insert random dates without repeats, random time without duplicates, random characters, and random data from certain custom list without repeats as well.

Insert random dates (excluding weekends) without repeats by Kutools for Excel
Insert random dates without repeats

Insert random time data without repeats by Kutools for Excel
Insert random time data without repeats

Insert random characters with specified string length by Kutools for Excel
Insert random characters with specified string length

Insert random data from certain custom list without repeats by Kutools for Excel
Insert random data from certain custom list without repeats


Related article:

Generate random character strings in a range

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!