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)

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 Shortcut Key Assignments

Shortcut keys are great timesavers when you don't want to remove your hands from the keyboard to mess with the mouse. ...

Discover More

Removing Spaces

Need to get rid of spaces in a range of cells? There are two ways you can approach the task, as described here.

Discover More

Engineering Calculations

Need to normalize your data in some way so that all your values are in a given format? This tip presents a number of ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

##### More ExcelTips (ribbon)

Using the EOMONTH Function

If you need to determine the date of the last day in a month, it's hard to beat the flexibility of the EOMONTH function. ...

Discover More

Returning the MODE of a Range

The MODE function is used to determine the most frequently recurring value in a range. This tip explains how to use the ...

Discover More

Indirect References to a DSUM Parameter

Indirect references can be very helpful in formulas, but getting your head around how they work can sometimes be ...

Discover More
##### Subscribe

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

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 five more than 4?

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.