# Rand

The Excel RAND function generates a random number greater than or equal to 0 and less than 1. Whenever the spreadsheet is opened or edited, the value is recalculated.

## Syntax

=RAND()

The Rand function does not need any arguments.

## Example 1: Basic use of the Rand function

You can try out the Rand function using the editor below. ### Explanation

The value in cell A1 is chosen randomly between 0 (including 0) and 1 (excluding 1). So the value will be something like 0.65691253052.

## Example 2: Generate a number between two specific numbers

We can use the value generated from Rand to create a random value in any range we choose. For example, if we want a random number between 5 and 15, we can use `=5 + (15-5) * RAND()`. Like in the example below. ### Explanation

To create an Excel formula that generates a random value in a range of your choosing, use the following formula:

For a value between x (inclusive) and y (exclusive):

`=x + (y - x) * RAND()`

## Questions

How do I generate a random number that doesn’t change when editing the spreadsheet?

You can generate a number using RAND() like normal and then change it to a fixed value by pressing F9.

How do I generate a random number in a specific range?

Use the formula `=x + (y - x) * RAND()` for a number between x and y. See the example above to see this in action.

## Drawbacks

• Not often do you need a number that recalculates with every edit of the Excel sheet. Therefore, changing the random value to be exact (by using F9) is a good trick to learn.