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

Protecting Headers and Footers

If you don't want the information in a header of footer to be changed by users of your document, there are a couple of ...

Discover More

Catching Single-Letter Spelling Errors

There have been times when I've reviewed my writing and found lots of "lone letters," detached by a single space from the ...

Discover More

First and Last Names in a Page Header

When you have a worksheet that includes a long list of names, you may want the first and last names on each page to ...

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 COUNTIF with Colors

Excel allows you to easily format cells with different fonts, borders, and colors. If you want to count the number of ...

Discover More

Returning the Left-most Characters

When working with text in a formula, you may need to extract the left-most characters from a string of text or from a ...

Discover More

Understanding the VLOOKUP Function

Functions are at the heart of Excel's power in working with data. One of the most misunderstood functions provided by ...

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 0 + 1?

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.