Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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

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

Randomly insert whole numbers / dates / time between two numbers/dates/times without repeats

Kutools for Excel's Insert Random Data utility enables to insert random integers (whole numbers) between two certain numbers easily, randomly insert a series of dates (only workdays, or only weekends, or no limitation) between two dates, randomly insert a series times between two times, or generate random text strings with certain length. And the Unique values option will prevent from inserting duplicates. Full Feature Free Trial 60-day!


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 - Combines more than 300 Advanced Functions and Tools for Microsoft Excel

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

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:

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 time data without repeats by Kutools for Excel

Insert random characters with specified string length by Kutools for Excel

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


Demo: insert random (integer) numbers between two numbers without repeats in Excel

In this Video, the Kutools tab and the Kutools Plus tab are added by Kutools for Excel. If need it, please click here to have a 60-day free trial without limitation!


Related article:

Generate random character strings in a range


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Screen Shot of Excel (with Office Tab installed)

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
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.
    Prashant · 2 years ago
    I need random incremental decimal values in a range.

    range
    22.1234 to 79.1234

    and from row 1 to row 300.

    how to do it........?
  • To post as a guest, your comment is unpublished.
    Percy · 3 years ago
    5. Try to accomplish the following with your prior knowledge of basic Excel programming. [6]
    5.1 Let’s say you’re interested in studying student attitudes toward climate change. If you
    wanted to randomly sample 50 students out of 643 at a local school, you would need
    to begin by creating a numbered list of all 643 students (student =1; student =2,
    student =3 and so forth). Then all you would need to do is to generate a set of random
    numbers with a range from 1 to 643. Use Excel to accomplish this task. Arrange your
    list from smallest to largest number.

    5.2 Although people sometimes confuse random assignment with random sampling, the
    two are really quite different. With random sampling, the goal is to choose a
    representative set of cases from the full population under consideration. With random
    assignment, the goal is usually to give all participants and equal chance of being
    assigned to each experimental condition (regardless of how representative the
    participants are).
  • To post as a guest, your comment is unpublished.
    Helena Scott · 3 years ago
    i just want to win PCH 10,000.00 can you help
  • To post as a guest, your comment is unpublished.
    Helena Scott · 3 years ago
    i would like to random my number 5035 4902 4950 4944 ID 4857-62 4650 tv276 5979 3818
  • To post as a guest, your comment is unpublished.
    nicola · 4 years ago
    good website I helped me a lot