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

Using InputBox to Get Data

Need your macro to get some input from a user? The standard way to do this is with the InputBox function, described in ...

Discover More

Adding Lines to a Document

Lines are one of the most common graphic elements to be added to documents. Here's how you can add the lines you want.

Discover More

Finding the Previous Work Day

Excel has a number of functions that are available as an add-on in the Analysis ToolPak. One of these functions allows ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Using a Week Number as One Criterion in a Formula

The SUMIFS function can be quite powerful in conditionally summing information based on criteria you specify. This tip ...

Discover More

Using the COLUMN Function

Need to know the column number for use in a formula? The worksheet function you want is the COLUMN function, described in ...

Discover More

Making VLOOKUP Case Sensitive

The VLOOKUP function, like other lookup functions in Excel, is not case sensitive. In other words, it doesn't matter ...

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 5 + 3?

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.