Excel RAND Function: Generate Random Numbers Step by Step
By Dr. Zubair Khalid, DVM, MS, PhD ·

The Excel random number function RAND returns a decimal greater than or equal to 0 and less than 1, and it produces a new value every time the worksheet recalculates [1]. That single behavior explains both its power and its main annoyance: the numbers move whenever anything changes. This article shows the syntax, a worked example, and the exact steps to freeze values when you need them to stay put.
Quick Answer
=RAND()takes no arguments and returns a decimal in the range $[0, 1)$ [1].- To get a decimal between two numbers $a$ and $b$, use
=RAND()*(b-a)+a[1]. - To get a whole number, use
=RANDBETWEEN(bottom, top), which returns an integer between the two values you specify [2]. - Every recalculation, including pressing F9, generates new numbers for any cell using
RAND[1]. - To keep the numbers, copy the cells and use Home > Paste > Paste Values.
Syntax
RAND has no arguments at all. You type the empty parentheses and that is the whole formula [1].
| Argument | Required? | Meaning |
|---|---|---|
| (none) | N/A | RAND takes no arguments and returns a random real number greater than or equal to 0 and less than 1 [1] |
If you want integers instead, RANDBETWEEN does take arguments [2].
| Argument | Required? | Meaning |
|---|---|---|
| Bottom | Required | The smallest integer RANDBETWEEN will return [2] |
| Top | Required | The largest integer RANDBETWEEN will return [2] |
How It Works
RAND returns an evenly distributed random real number greater than or equal to 0 and less than 1 [1]. "Evenly distributed" means every value in that interval has an equal chance of appearing. If you generate 400 numbers with RAND, the average is always approximately 0.5, and around 25 percent of the results fall in each quarter of the interval from 0 to 1 [3]. That is what a uniform random number looks like in practice.
The values are independent. If the number in one cell happens to be 0.99, that tells you nothing about the values in the other cells [3]. This independence is what makes RAND useful for simulation, sampling, and shuffling.
The recalculation rule is the part that surprises people. A new random number is generated for any formula using RAND whenever the worksheet is recalculated, whether that happens because you entered a formula or data in a different cell, or because you pressed F9 to recalculate manually [1]. The same is true for RANDBETWEEN [2].
To scale RAND into a range you actually want, use the standard formula from Microsoft's documentation [1]:
$$=RAND() \times (b - a) + a$$
For example, =RAND()*100 gives a decimal from 0 up to but not including 100, and =RAND()*90+10 gives a decimal from 10 up to but not including 100.
Worked Example
The table below tracks ten students with a score column, a random decimal from RAND, and a random integer from RANDBETWEEN. The formulas sit in row 2 and are filled down.
| Row | A (Student) | B (Score) | C (Random Decimal) | D (Random Integer) |
|---|---|---|---|---|
| 1 | Student | Score | Random Decimal | Random Integer |
| 2 | Ana | 78 | =RAND() -> displays 0.175228 | =RANDBETWEEN(1,100) -> displays 86 |
| 3 | Ben | 85 | =RAND() -> displays 0.00378852 | =RANDBETWEEN(1,100) -> displays 85 |
| 4 | Cara | 92 | =RAND() -> displays 0.886961 | =RANDBETWEEN(1,100) -> displays 53 |
| 5 | Dan | 67 | =RAND() -> displays 0.828038 | =RANDBETWEEN(1,100) -> displays 97 |
| 6 | Eve | 74 | =RAND() -> displays 0.0997731 | =RANDBETWEEN(1,100) -> displays 13 |
| 7 | Finn | 88 | =RAND() -> displays 0.0339045 | =RANDBETWEEN(1,100) -> displays 68 |
| 8 | Gus | 95 | =RAND() -> displays 0.352901 | =RANDBETWEEN(1,100) -> displays 75 |
| 9 | Hana | 71 | =RAND() -> displays 0.692406 | =RANDBETWEEN(1,100) -> displays 44 |
| 10 | Ivy | 83 | =RAND() -> displays 0.865721 | =RANDBETWEEN(1,100) -> displays 42 |
| 11 | Jax | 79 | =RAND() -> displays 0.710733 | =RANDBETWEEN(1,100) -> displays 70 |
The steps to build it:
- In cell C2, enter
=RAND(). This generates a random decimal between 0 and 1. - In cell D2, enter
=RANDBETWEEN(1,100). This generates a random integer between 1 and 100. - Select C2:C11, then press Ctrl+D to fill the
RANDformula down to C11. - Select D2:D11, then press Ctrl+D to fill the
RANDBETWEENformula down to D11. - To freeze the random values, select C2:D11, copy, then use Home > Paste > Paste Values.
Step 5 matters because the values in columns C and D will change the moment anything recalculates. Paste Values replaces the live formulas with the numbers they currently show, so the table stops moving. If you want a formula that converts RAND to a fixed value without copying, Microsoft documents a different route: enter =RAND() in the formula bar, then press F9, which changes the formula to a random number and leaves you with just a value [1].
More Examples
Random decimal between 10 and 50. Use =RAND()*(50-10)+10. The result is greater than or equal to 10 and less than 50.
Random whole number between 1 and 6, like a die roll. Use =RANDBETWEEN(1,6). Both bounds are included, so 1 and 6 are possible results [2].
Random whole number between 0 and 99. Microsoft's own example table includes a random whole number greater than or equal to 0 and less than 100 [1]. =RANDBETWEEN(0,99) matches that description.
A block of random numbers at once. If you have a version of Excel that supports dynamic arrays, RANDARRAY returns an array of random numbers, and you can specify the number of rows and columns to fill, the minimum and maximum values, and whether to return whole numbers or decimals [4]. The syntax is =RANDARRAY([rows],[columns],[min],[max],[whole_number]) [4]. With no arguments, it returns a single value between 0 and 1 [4]. The minimum must be less than the maximum, otherwise RANDARRAY returns a #VALUE! error [4].
Random sampling for a simulation. A Monte Carlo simulation uses random numbers to drive a lookup. Microsoft's example generates 400 random numbers by copying RAND() down a column, then uses VLOOKUP against a probability table so that each random number maps to a demand level [3]. Pressing F9 recalculates the random numbers and refreshes the simulated probabilities [3]. If you want to try a lighter version of this idea without a spreadsheet, the Random Number & Decision Picker Wheel does the drawing for you.
Combining with other functions. Once you have random values, you often need to summarize them. The SUM function totals a range, and the COUNT function tells you how many numeric cells you have. If you want to round a scaled random decimal to a set number of digits, the ROUND function handles that. For a refresher on how formulas are structured in general, see how to make a formula in Excel.
Errors and How to Fix Them
#VALUE! from RANDARRAY. This appears when the minimum number argument is not less than the maximum number argument [4]. Swap the two values so the minimum is smaller.
#NUM! from RANDBETWEEN. This appears when the bottom argument is larger than the top argument. Check that the first number you typed is the smaller one.
Numbers that will not stay still. This is not an error, it is how RAND works. Every recalculation produces new values [1]. Freeze them with Paste Values when you need a fixed set.
A formula that shows as text. If you see the formula itself instead of a number, the cell is formatted as text. Reformat the cell as General and re-enter the formula.
Common Mistakes
- Expecting the numbers to stay put.
RANDrecalculates constantly, so any edit elsewhere on the sheet can change your values [1]. Fix: copy the range and use Home > Paste > Paste Values before you build anything on top of it. - Using
RANDwhen you need integers.RANDalways returns a decimal between 0 and 1 [1]. Fix: useRANDBETWEEN(bottom, top)for whole numbers [2]. - Assuming
RANDBETWEENexcludes the top value. It includes both bounds, so=RANDBETWEEN(1,100)can return 1 and can return 100 [2]. Fix: adjust the bounds if you need an exclusive upper limit. - Forgetting that
RANDhas no arguments. Typing=RAND(1,100)is not valid syntax [1]. Fix: write=RAND()and scale it with arithmetic, or switch toRANDBETWEEN. - Sorting or filtering on a live
RANDcolumn. The sort triggers a recalculation, so the values change and the order no longer matches what you saw. Fix: paste values first, then sort. - Treating one random draw as a result. A single number tells you nothing about a distribution. Fix: generate many rows and summarize them, the way a simulation does with 400 iterations [3].
Limitations
RAND gives you a uniform distribution only. Every value between 0 and 1 is equally likely, so it cannot directly produce a normal distribution, a weighted distribution, or any other shape. You have to build that shape yourself, for example by mapping random numbers through a lookup table, which is exactly what the Monte Carlo approach does [3].
The values are also not reproducible. There is no seed argument, so you cannot regenerate the same sequence later, and you cannot audit a result by rerunning it. Once you paste values, the original formula is gone. If you need a record of what was drawn, save the frozen values in a separate column or sheet before you overwrite anything. Finally, RAND is not suitable for cryptographic or security purposes, since it is designed for spreadsheet calculation, not for protecting data.
Frequently Asked Questions
How do I stop RAND from changing in Excel?
Copy the cells containing RAND, then use Home > Paste > Paste Values to replace the formulas with the numbers they currently show. Microsoft also documents a formula-bar method: enter =RAND(), press F9 to convert the formula to a random number, and the cell keeps just that value [1]. Both approaches remove the live formula, so the number stops updating.
What is the difference between RAND and RANDBETWEEN?
RAND returns a decimal greater than or equal to 0 and less than 1 and takes no arguments [1]. RANDBETWEEN returns a whole number between a bottom and a top value that you supply, and both bounds are included [2]. Use RAND when you need a continuous value, and RANDBETWEEN when you need a count, an index, or a die roll.
How do I generate a random number between two values?
For a decimal, use =RAND()*(b-a)+a, where $a$ is the low end and $b$ is the high end [1]. For a whole number, use =RANDBETWEEN(a,b) [2]. For example, =RAND()*90+10 gives a decimal from 10 up to but not including 100, while =RANDBETWEEN(10,100) gives an integer from 10 through 100.
Can I generate many random numbers at once?
Yes. RANDARRAY returns an array of random numbers, and you can set the number of rows and columns, the minimum and maximum, and whether the output is whole numbers or decimals [4]. The array spills into the surrounding cells when you press Enter [4]. If your version of Excel does not support it, fill RAND down a column instead.
Why did my random numbers change when I edited another cell?
Because that edit triggered a recalculation, and any formula using RAND produces a new value on every recalculation [1]. The same applies to RANDBETWEEN [2]. This is expected behavior, not a bug. Freeze the values with Paste Values as soon as you have the set you want to keep.
References
- RAND function | Microsoft Support
- RANDBETWEEN function | Microsoft Support
- Introduction to Monte Carlo simulation in Excel | Microsoft Support
- RANDARRAY function | Microsoft Support
Further Reading
- Broman KW, Woo KH (2018). Data Organization in Spreadsheets. The American Statistician
- Ziemann M, Eren Y, El-Osta A (2016). Gene name errors are widespread in the scientific literature. Genome Biology