Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Random Numbers in a Range

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.

For Excel 2007 users the RANDBETWEEN function is built into the program. If you are using an earlier version of Excel, RANDBETWEEN is a part of the Analysis Toolpak. If you get an error when you try to use the function, you can make sure the toolpak is loaded in this manner:

  1. Choose Add-Ins from the Tools menu. Excel displays the Add-Ins dialog box.
  2. Make sure the Analysis Toolpak check box is selected.
  3. Click on OK.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2812) applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003 | 2007

Related Tips:

Organize Your Data! Using the powerful sorting capabilities of Excel can help you get your data into just the order you need. Find out how you can use the full capabilities of sorting to your benefit. Check out ExcelTips: Serious Sorting today!

 

Comments for this tip:

RLUCE    26 Jan 2012, 08:27
I CANNOT GET THIS TO WORK, EXCEL 2003
=RANDBETWEEN(lower, upper)
I have it entered as below.
=RANDBETWEEN(50, 99)

Leave your own comment:

*Name:
Email:
  Notify me about new comments for this tip
Hide my email address
*Text:
*What is 2+3? (To prevent automated submissions and spam.)