Excel.Tips.Net Welcome toExcel.Tips.Net

Helpful Links

Tips.Net Home
ExcelTips Home
Ask an Excel Question
Make a Comment

Tips.Net Store

ExcelTips FAQ
ExcelTips Premium

Learn Access Now
Free Printable Forms

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
ExcelTips Site

Newest Tips

Converting to Octal

Filtering Columns for Unique Values

Printing Multiple Worksheets on a Single Page

Changing the Default Font

Creating a Drawing Object

Determining a Value of a Cell

Understanding Macros

 

AutoFill with Random Numbers

Summary: AutoFilling is a great tool in Excel; it allows you to place a wide range of values into cells. If you want to use it to add random numbers to a worksheet, you'll be disappointed—Excel won't do it. You can, however, use one of the tools available in the Analysis ToolPak to generate a whole bunch of random numbers. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)

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. Choose Data Analysis from the Tools menu. If you are using Word 2007, you display the Data tab of the ribbon and then click Data Analysis in the Analysis group. (If you don't see the Data Analysis option on the Tools menu or, in Word 2007, you don't see the Analysis group on the Data tab of the ribbon, it means that you don't have the Analysis ToolPak enabled.) Excel displays the Data Analysis dialog box. (Click here to see a related figure.)
  2. In the list of functions in the dialog box, choose Random Number Generation.
  3. Click on OK. Excel displays the Random Number Generation dialog box. (Click here to see a related figure.)
  4. 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.)
  5. Click on OK.

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

Save Time! ExcelTips has been published weekly since late 1998. Past issues of ExcelTips are available in convenient ExcelTips archives. Have your own enhanced archive of ExcelTips at your fingertips, available to use at any time!
 
Check out ExcelTips Archives today!