Excel has two built-in functions that generate random numbers
RAND() produces a decimal between 0 and 1 each time you open or recalculate the sheet. RANDBETWEEN() produces a whole number within a range you specify. Both recalculate automatically whenever the sheet updates, so the numbers change constantly — useful for simulations, sampling, or testing formulas with different values.
The choice between them depends on what you need. RAND() is simpler but gives you decimals. RANDBETWEEN() requires you to set a minimum and maximum, but delivers whole numbers that are often easier to work with.
Key Takeaways
- RAND() generates a random decimal between 0 and 1 with no parameters needed — just type =RAND() in a cell.
- RANDBETWEEN(bottom, top) generates a random whole number between two values you specify, such as =RANDBETWEEN(1,100).
- Both functions recalculate every time Excel updates the sheet, so the numbers change unless you convert them to static values.
- To lock a random number in place, copy the cell and paste it as values only using Paste Special.
- You can combine RAND() with arithmetic to scale it to any range — for example, =RAND()*50 produces a decimal between 0 and 50.
Using RAND() for decimals between 0 and 1
Click any empty cell and type =RAND(), then press Enter. Excel fills the cell with a random decimal — something like 0.472 or 0.891. Each time you press F9 or make any change to the sheet, that number changes to a new random value.
RAND() always produces a result between 0 (inclusive) and 1 (exclusive), meaning you will never get exactly 1 but might get very close. If you need a decimal in a different range, multiply RAND() by the size of the range. For example, =RAND()*100 gives you a decimal between 0 and 100, and =RAND()*50+25 gives you a decimal between 25 and 75.
Using RANDBETWEEN() for whole numbers in a specific range
Click any empty cell and type =RANDBETWEEN(1,100), replacing 1 and 100 with your minimum and maximum. Press Enter. Excel fills the cell with a random whole number within that range — 1, 100, or anything between them.
The syntax is =RANDBETWEEN(bottom, top). The bottom value and top value are both included in the possible results. If you type =RANDBETWEEN(10,20), you can get 10, 20, or any integer in between. The function does not work with decimals — it always rounds to whole numbers.
Stopping random numbers from changing
By default, RAND() and RANDBETWEEN() recalculate every time Excel recalculates the sheet — when you edit a cell, press F9, or even just reopen the file. If you want to lock a random number in place so it never changes, you must convert it from a formula to a static value.
Click the cell with the random number. Copy it (Ctrl+C). Right-click and select Paste Special, or press Ctrl+Shift+V. In the Paste Special dialog, click the Values radio button and click OK. The formula disappears and the number stays fixed. You can now edit other cells without affecting this one.
Creating a column of different random numbers
Click a cell and enter =RANDBETWEEN(1,100) (or =RAND() if you prefer decimals). Press Enter. Click the same cell again, then grab the small square at the bottom-right corner of the cell and drag it down as far as you need. Excel copies the formula down and generates a new random number in each row.
Each cell gets its own independent random number — they do not copy the same value. If you drag down 10 rows, you get 10 different random numbers. All of them will recalculate together whenever the sheet updates, so they stay independent and random.
Combining random numbers with other formulas
Random numbers are useful inside other formulas. For example, =CHOOSE(RANDBETWEEN(1,3),"Red","Blue","Green") picks a random color name. The RANDBETWEEN(1,3) generates 1, 2, or 3, and CHOOSE() returns the corresponding item from the list.
You can also use random numbers for weighted sampling. =IF(RAND()<0.3,"Yes","No") returns "Yes" about 30 percent of the time and "No" about 70 percent of the time. The RAND() generates a decimal, and IF() compares it to your threshold. This pattern works for any probability you want to test.
Frequently Asked Questions
Why do my random numbers keep changing?
RAND() and RANDBETWEEN() recalculate automatically whenever Excel updates the sheet — when you edit a cell, press F9, or reopen the file. If you want them to stay fixed, copy the cell and use Paste Special to paste values only, which converts the formula to a static number.
Can I generate random numbers without decimals?
Yes, use RANDBETWEEN(). It always produces whole numbers. RAND() produces decimals, but you can multiply it by a whole number and use INT() to round down — for example, =INT(RAND()*100) gives you a whole number between 0 and 99.
What is the difference between RAND() and RANDBETWEEN()?
RAND() generates a decimal between 0 and 1 with no parameters. RANDBETWEEN() generates a whole number between two values you specify. Use RAND() when you need decimals or want to scale the result yourself; use RANDBETWEEN() when you need whole numbers in a specific range.
Can I set a seed so the same random numbers appear each time?
Excel does not have a built-in seed function like some other programs. Once you generate a random number, it changes every time the sheet recalculates. To keep specific numbers, convert them to values using Paste Special, or use a third-party add-in that supports seeding.
How do I generate random numbers without recalculating?
Copy the cell with the random formula, then right-click and choose Paste Special. Select Values and click OK. This replaces the formula with the number it produced, so it never changes again. You can also press Ctrl+Shift+V as a shortcut to Paste Special.