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

Creating Custom Labels

There is a whole passel of labels pre-defined in Word. You are not limited to this passel, however; Word allows you to define ...

Discover More

Keeping a Picture Title with the Picture

Pictures and their titles go together like peanut butter and jelly. (Wow, did I just say that?) Seriously, pictures and ...

Discover More

Read-Only Embedded Fonts

If you receive a document from somebody else, you might not be able to edit it if the document contains fonts that you don't ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Counting the Number of Blank Cells

If you need to count the number of blank cells in a range, the function to use is COUNTBLANK. This tip discusses the ...

Discover More

Getting the Name of the Parent Workbook

If you need to insert into a cell the name of the workbook in which a worksheet is contained, you can use the CELL function. ...

Discover More

Cleaning Text

You can use the CLEAN worksheet function to remove any non-printable characters from a cell. This can come in handy when you ...

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 7 + 6?

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.