# The RAND Function: Syntax and Examples The RAND is an Excel math and trigonometry function that returns a random value between 0 and 1. Excel uses the Mersenne Twister algorithm for this.

It is one of the oldest Excel functions, so it can be used even with Excel 2003.

## RAND Syntax

``RAND()``

### Required Arguments

The RAND function does not take any arguments.

## RAND Function Examples

When used on its own, RAND will return a random number between 0 and 1. For example 0.

Note: The value will change every time you make any changes to your sheet or reopen it. See here to prevent this from happening.

### Generate a Random Real Number from a Range

To generate a random real number withing a range, use the following formula:

` =RAND()*(b-a)+a `

For example, to generate a number between 20 and 30, the formula would be:

` =RAND()*(30-20)+20 `

Note: A simpler way would be to use the RANDBETWEEN() function.

### Generate a Random Whole Number

To generate a random whole number, use the following formula:

` =INT(RAND()*(b-a)+a) `

So with the previous example where we had the range 20:30, the value would have been 23, instead of 22.70093.

### Recalculate RAND

RAND is recalculated every time you make a change in your worksheet or open it again. But if you want to manually recalculate RAND, press F9 and it will generate a new number for you.

Note: Pressing F9 will recalculate RAND in every cell with this formula, not just the one that is selected.

### Stop RAND from Changing

If you want to stop the cell from recalculating, there are two options:

1. Select the cell with the RAND function > click on the formula bar > press F9.
2. Select the cell or cells with a RAND function > copy > paste values only

Using either of these options will leave you with a value instead of the formula.

### Calculate RAND in multiple cells

To generate more than one random number, select the cells, enter RAND() in the formula bar and press Ctrl + Enter.

### Calculate Random Time using RAND function

RAND function can also be used to calculate a random time. To do this, you’ll need to change the cell’s number format to “Time”.