Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Random Numbers in a Range.

Random Numbers in a Range

by Allen Wyatt
(last updated October 15, 2016)

3

Excel provides a power function that allows you to easily return a random integer number within a range. For instance, you can use the RANDBETWEEN function to return a random integer number between 50 and 99, or between –25 and 0. The syntax for the function is as follows:

=RANDBETWEEN(lower, upper)

All you need to do is provide the lower and upper values. If the first number you provide is actually higher than the second number, then RANDBETWEEN returns a #NUM! error.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12364) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Random Numbers in a Range.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Printing Multiple Label Copies when Merging

Need to print more than one copy of mail-merge labels? There are a number of different approaches you can take to getting the ...

Discover More

Using Excel for Timing

Excel allows you to store times in a worksheet. If you want to use Excel to time certain events, there are a couple of ways ...

Discover More

Adding a Break to Your Document

Want to modify the way your text flows between pages in a document? Word allows you to insert several types of breaks that ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

The EDATE Function

Want to figure a date a certain number of months in the future or past? The EDATE function may be just what you need for your ...

Discover More

Finding the Date Associated with a Negative Value

When working with data taken from the real world, you often have to determine which certain conditions were met, such as when ...

Discover More

Using the INT Worksheet Function

The INT function allows you to convert a value to an integer. The effect the function has depends on the characteristics of ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four less than 9?

2016-10-17 11:34:08

David Bonin

Excel's random number functions tend to execute slowly. Generating a significant list takes time. Also, as noted below, debugging formulas that change every time they are executed can be maddening. Even worse, converting uniformly distributed

When I had to generate thousands of random numbers for a large Monte Carlo simulation, I used the Rand Corporation's table of "A Million Random Digits with 100,000 Normal Deviates". It's available for download for free. From there, I merely chose a random enough starting point (my pseudo-seed) and just started pulling numbers.

When I wanted to run a different simulation, I picked another starting point (whose range of numbers did not overlap an earlier-used range) and started picking more numbers.

Best part, I was using random values which did not change or refresh unless I wanted them to, and execution speed was much faster.


2016-10-17 10:00:37

mike

Excel will not randbetween fractions or decimals as expected...
Take hi and lo fractions (decimals) times 100; do the ranbetween on those whole numbers; then divide the randbetween results by 100.
Ex.: Randbetween for decimals:
a) with decimals 0.23 and -0.56.
b) times 100 is 23 and -56.
c) Randbetween on 23 and -56 divided by 100 is
d) in decimals


2016-10-15 14:31:35

Steve

Because I often need to document my random selection, as well as sort in ascending order, and the randbetween function returns new values every time a new operation is performed the copy and paste values functions are useful. If I need a population of 40, I will use this function to select 60 items. Then copy and paste values for all 60 selections, create a break between the 40 needed and the 20 alternates. The 40 items can then be sorted in ascending order, with the remaining alternates used as needed in the order selected. For documentation purposes, I describe this procedure since the formulas are no longer in the cells.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.