How to Use Random Function in Microsoft Excel

By Craig Witt

Microsoft Excel is one of the world's leading spreadsheet applications. Included as part of the Microsoft Office suite of productivity products, the program allows users to perform calculations; create graphs, charts and pivot tables; and automate behavior by creating macros in the VBA programming language. Excel offers many built-in functions that let users create and run calculations quickly and easily. The random number generator is one of these functions.

Step 1

Open Microsoft Excel.

Step 2

Create two values between which you want a random number generated. For this example, enter "1" in cell A1 and "10" in cell A2, omitting the quotation marks in both cases.

Step 3

Type the implementation of the random number function show below into cell A3:=RAND()*(A2-A1)+A1The random function is designed to return a random value greater than or equal to 0 and less than 1. By taking the difference between the upper limit of the range (in cell A2) and the lower limit of the range (in cell A1) and then adding the lower range value, you generate a random number between those values.

Step 4

Press the "Enter" key to confirm the function entered in the previous step and return a random number within the specified range. To return only whole numbers, right-click the cell containing the function and select the "Format Cells" option. Select the first tab on the resulting screen, choose "Number" from the category list, specify a decimal place value of 0 and then click "OK."

Tips & Warnings

  • You do not have to generate a random number within a range. Simply enter "=RAND()" (without quotation marks) in a cell and press the "Enter" key. Excel will return a random value greater than or equal to 0 and less than 1.