Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. 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: AutoFill with Random Numbers.

AutoFill with Random Numbers

by Allen Wyatt
(last updated September 14, 2016)

3

Excel includes a feature that allows you to automatically fill a range of cells with information you have placed in just a few cells. For instance, you could enter the value 1 in a cell, and then 2 in the cell just beneath it. If you then select the two cells and drag the small black handle at the bottom right corner of the selection, you can fill any number of cells with incrementing numbers. This AutoFill feature sure beats having to type in all the values! You may wonder if there is a similar way to use the AutoFill feature to place random numbers in a range. Unfortunately, the AutoFill feature was never meant for random numbers. Why? Because AutoFill uses predictive calculations to determine what to enter into a range of cells. For example, if you entered 1 into one cell and 5 into the next, highlighted the cells and then used AutoFill, the next number entered in the cell below would be 9 because Excel can deduce that the increment is 4. It is a constant increment that can be predicted. Random numbers on the other hand are, well, random. By nature they cannot be predicted, else they wouldn't be random. Therefore the predictive nature of AutoFill cannot be applied to random numbers. However, there are ways around this. One is to simply use the various formulas (using RAND and RANDBETWEEN) that have already been adequately covered in other issues of ExcelTips. These formulas can quickly and easily be copied over a range of cells, using a variety of copying techniques. Another approach is to use a feature of the Analysis ToolPak which makes putting random numbers into a range of cells pretty easy. Just follow these steps:
  1. Display the Data tab of the ribbon.
  2. Click Data Analysis in the Analysis group. Excel displays the Data Analysis dialog box. (See Figure 1.)
  3. Figure 1. The Data Analysis dialog box.

  4. In the list of functions in the dialog box, choose Random Number Generation.
  5. Click on OK. Excel displays the Random Number Generation dialog box. (See Figure 2.)
  6. Figure 2. The Random Number Generation dialog box.

  7. Using the controls in the dialog box, indicate the parameters you want used in generating a range of random numbers. (Make sure that you specify a range of cells in the Output Options area of the dialog box.)
  8. Click on OK.
If you don't see the Analysis group on the Data tab of the ribbon (setp 2), it means that you don't have the Analysis ToolPak enabled. Follow these steps to enable it:
  1. Display the Excel Options dialog box. (In Excel 2007 click the Office button and then click Excel Options. In Excel 2010 and Excel 2013 display the File tab of the ribbon and then click Options.)
  2. At the left side of the dialog box click Add-Ins.
  3. At the bottom of the dialog box use the Manage drop-down list to select Excel Add-ins.
  4. Click the Go button. Excel displays the Add-Ins dialog box. (See Figure 3.)
  5. Figure 3. The Add-Ins dialog box.

  6. Select the check box next to Analysis ToolPak.
  7. Click OK.
The Analysis group should now appear on the Data tab of the ribbon. When you use the Random Number Generation tool, you might be a bit overwhelmed by all the options it provides you. You can find a good explanation of all the dialog box options (step 5) at this website:
http://www.bettersolutions.com/excel/EUN147/YI231420881.htm

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8810) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: AutoFill with Random Numbers.

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

Specifying Index Section Dividers

When adding an index to your document, you can use one of the available field switches to specify how the index should be ...

Discover More

Sticking with the Dashes

By default, dashes don't "stick" to the text that follows them. Here's one way around this normal formatting convention.

Discover More

Changing the Reference in a Named Range

Define a named range today and you may want to change the definition at some future point. It's rather easy to do, as ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

AutoFilling with the Alphabet

If you need to fill a number of cells with a specific sequence of characters (such as the alphabet), there are several ways ...

Discover More

Fast AutoFill

Want to fill a long column with predictive data? It's easy to do by using AutoFill and a double-click of the mouse.

Discover More

AutoFilling with Weekdays

Need to fill a range of cells with the days of the week? Excel makes it easy to do so using AutoFill.

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 8Mpixels. 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 - 0?

2014-03-09 21:11:23

fred

agree: tips or excel could explain it with their usual examples better


2014-03-08 20:44:44

Martin Nicol

Unless you are into statistics, forget the add-in, I wasted half an hour trying to use it. Rand_between is all I will need.


2014-03-08 10:50:36

E Nora

=rand() produces a number. Copy the formula to all other areas where random numbers are needed. Because this is a formula, every time the worksheet is recalculated, the number will change, so for a stable numbers, copy and paste values. =randbetween(a,b,) allows you to specify the limits of the numbers, otherwise, it works as =rand()


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.