One way to generate random numbers in Excel is with the **RAND** function. By itself, the function generates a limited range of random numbers, but by using **RAND** in formulas with other functions, the range of values can easily be expanded so that:

- By specifying the high and low values of a range,
**RAND**can be made to return random numbers within a specified range, such as 1 and 10 or 1 and 100. - The function's output can be reduced to integers by combining the function with the
**TRUNC**function, which truncates or removes all decimal places from a number.

The **RAND** function returns an evenly distributed number greater than or equal to 0 and less than 1. While it is normal to describe the range of values generated by the function as being from 0 to 1, in reality, it is more exact to say the range is between 0 and 0.999...

### RAND Function Syntax and Arguments

A function's syntax refers to the layout of the function and includes the function's name, brackets, comma separators, and arguments. The syntax for the **RAND** function is:

= RAND ( )

Unlike the **RANDBETWEEN** function, which requires high-end and low-end arguments to be specified, the RAND function accepts no arguments.

Several **RAND** function examples were used to produce the results shown in the above image.

- The first example enters the
**RAND**function by itself. - The second example creates a formula that generates a random number between 1 and 10 or 1 and 100.
- The third example generates a random integer between 1 and 10 using the
**TRUNC**function. - The last example uses the
**ROUND**function to reduce the number of decimal places for random numbers.

### Generating Numbers with RAND

Since the RAND function takes no arguments, it can easily be entered into any worksheet cell simply by clicking on a cell and typing:

= RAND ( )

The result is a random number between 0 and 1 in the cell.

**Generate Numbers Within a Range**

The general form of the equation used to generate a random number within a specified range is:

=RAND() * (High - Low) + Low

**High** and **Low** signify the upper and lower limits of the desired range of numbers. As an example, to generate a random number between 1 and 10 enter the following formula into a worksheet cell:

=RAND() * (10 - 1) + 1

### Generating Random Integers with RAND

To return an integer — a whole number with no decimal portion — the general form of the equation is:

=TRUNC ( RAND() *(High - Low) + Low)

Rather than remove all decimal places with the **TRUNC** function, we can use the following **ROUND** function in conjunction with **RAND** to reduce the number of decimal places in the random number to two.

=ROUND ( RAND() * (High - Low) + Low, Decimals)

### RAND Function and Volatility

The **RAND** function is one of Excel's volatile functions; this means that:

- The function recalculates
- Any formula that depends either directly or indirectly on a cell containing a volatile function also recalculates every time a change in the worksheet occurs.
- In worksheets or workbooks containing large amounts of data, volatile functions should be used with caution because they can slow down the program's response time due to the frequency of recalculations.

Forcing the RAND function to produce new random numbers without making other changes to a worksheet can be accomplished by pressing the **F9 **key on the keyboard. This forces the entire worksheet to recalculate including any cells containing the RAND function.

The **F9** key can also be used to prevent a random number from changing every time a change is made to the worksheet:

- Click on a worksheet cell where the random number is to reside.
- Type the function
**=RAND()**into the formula bar above the worksheet. - Press the
**F9**key to change the**RAND**function into a static random number. - Press the
**Enter**key on the keyboard to enter the random number into the selected cell.

Now, pressing **F9** again will have no effect on the random number.