RAND returns a random decimal that is at least 0 and less than 1. It takes no arguments, but the brackets are required: =RAND(). Every time the workbook recalculates, every RAND cell gets a new value.
Volatile: it changes constantly
RAND is a volatile function. Excel recalculates it whenever anything on the sheet changes, when you press F9, and when the workbook opens. That is what you want for simulations, but it is a problem when you need a number that stays put. To freeze random numbers, copy the cells and use Paste Special > Values, which replaces the formulas with the numbers they showed. Keep the formulas somewhere else if you may need a fresh draw.
Because the value is different each time, the examples on this page test properties that always hold, such as "the result is between 0 and 1", rather than showing a particular value.
Scaling and shifting
A number from 0 up to but not including 1 can be stretched to any range:
- A decimal between a and b:
=a + RAND() * (b - a). For 5 to 10: =5 + RAND()*5. - A whole number from 1 to 6:
=INT(RAND()*6) + 1. INT cuts the decimals off, so 0.999 times 6 becomes 5, plus 1 gives 6. - A yes or no with a given chance:
=IF(RAND()<0.3, "Yes", "No") says Yes about 30% of the time. - A coin flip:
=IF(RAND()<0.5, "Heads", "Tails").
For whole numbers, RANDBETWEEN is shorter. =RANDBETWEEN(1, 6) does the same as the INT formula.
Shuffling and sampling
RAND is the usual way to put a list in random order. Put =RAND() next to each item and sort by that column. In Microsoft 365, =SORTBY(A2:A9, RANDARRAY(ROWS(A2:A9))) shuffles the list without a helper column. To draw a random sample, take the first n rows of the shuffled list.
Practical points
- The result can never be exactly 1, so
INT(RAND()*n) never produces n. - Every RAND in a workbook is independent. Referring to one cell twice gives one value; typing RAND() twice gives two different values.
- Large numbers of RAND cells make a workbook slow, because every volatile cell and everything that depends on it recalculates on each change.
- RAND isn't suitable for security. It is for modelling, sampling and games.