Excel has three functions that generate random numbers, and which one you use depends on whether you need whole numbers or decimals
The most common function is RAND(), which creates a random decimal between 0 and 1 each time you open the spreadsheet or press F9. If you need whole numbers instead — say, random integers from 1 to 100 for a lottery or game — use RANDBETWEEN(). A third option, RANDARRAY(), fills multiple cells at once, but it only works in Excel 365 and newer versions.
All three recalculate automatically whenever the spreadsheet recalculates, which means the numbers change every time you edit a cell or press F9. If you need numbers that stay fixed, you will need to convert them to values afterward — a separate step covered below.
Key Takeaways
- RAND() produces decimals between 0 and 1; RANDBETWEEN() produces whole numbers within a range you specify.
- All random functions recalculate automatically, so the numbers change whenever you edit the spreadsheet unless you convert them to fixed values.
- To lock random numbers in place, copy the cells, then paste them as values using Paste Special.
- RANDARRAY() fills a block of cells with random numbers at once, but only works in Excel 365 and newer versions.
Using RAND() for decimals between 0 and 1
Type =RAND() into any cell and press Enter. Excel fills that cell with a random decimal — something like 0.472 or 0.891. The formula has no arguments, so you do not add anything inside the parentheses.
To scale this to a different range, multiply RAND() by the size of the range you want. For example, =RAND()*100 gives you a random decimal between 0 and 100. If you want a random decimal between 10 and 50, use =RAND()*40+10 (multiply by the range size, then add the starting point).
RAND() recalculates every time you press F9 or edit any cell in the spreadsheet. If you need the numbers to stay the same, copy the cells containing RAND(), right-click, choose Paste Special, select Values, and click OK. This replaces the formulas with the numbers they produced at that moment.
Using RANDBETWEEN() for whole numbers
Type =RANDBETWEEN(1,100) to get a random whole number between 1 and 100. The two numbers in parentheses are the bottom and top of your range — you can use any integers you want. =RANDBETWEEN(1,6) simulates a die roll; =RANDBETWEEN(1,52) simulates picking a card from a deck.
RANDBETWEEN() includes both the bottom and top numbers in its range. If you write =RANDBETWEEN(1,10), you can get 1, 2, 3, 4, 5, 6, 7, 8, 9, or 10 — not 0 to 9. This matters when you are trying to simulate something specific.
Like RAND(), RANDBETWEEN() recalculates whenever the spreadsheet recalculates. To freeze the numbers, copy the cells, use Paste Special, choose Values, and click OK.
Filling multiple cells at once with RANDARRAY()
If you have Excel 365 or Excel 2021 and later, RANDARRAY() fills a block of cells with random numbers in one step. Type =RANDARRAY(5,3) and press Ctrl+Shift+Enter (not just Enter). This creates a 5-row by 3-column block of random decimals between 0 and 1.
To generate whole numbers with RANDARRAY(), add RANDBETWEEN() inside it: =RANDARRAY(5,3,1,100) creates a 5-by-3 block of random integers between 1 and 100. The four numbers are: rows, columns, minimum value, and maximum value.
RANDARRAY() is faster than copying a single formula down and across, but only if your version of Excel supports it. Older versions will show a #NAME? error. If that happens, use RAND() or RANDBETWEEN() in a single cell and copy it down instead.
Converting random numbers to fixed values
Random formulas recalculate constantly, which is usually a problem. If you build a calculation on top of random numbers, those calculations will jump around every time the spreadsheet recalculates. To stop this, convert the formulas to the numbers they produced.
Select the cells containing the random formulas. Copy them (Ctrl+C). Right-click and choose Paste Special. In the dialog, select Values and click OK. The formulas disappear and are replaced by the numbers they generated at that moment. Those numbers will not change.
If you are using RANDARRAY(), select the entire block it created, copy it, then use Paste Special > Values to lock all the numbers at once.
Why random numbers recalculate and when that matters
Excel treats RAND(), RANDBETWEEN(), and RANDARRAY() as volatile functions — they recalculate whenever the spreadsheet recalculates, not just when their inputs change. This happens when you edit any cell, press F9, or open the file.
This is useful if you are running a simulation or a game where you want new random numbers each time. It is a problem if you are using random numbers as input to other calculations and you need those calculations to stay stable. In that case, convert the random numbers to values as described above.
You can also press Ctrl+Shift+F9 to recalculate only the current sheet, which gives you more control over when the random numbers change.
Common uses for random numbers in spreadsheets
Random numbers are useful for sampling data, running simulations, and creating test data. If you have a list of 500 names and want to pick 50 at random, add a column of RAND() next to the names, sort by that column, and take the top 50. Then delete the random column.
For simulations — like predicting how many customers might arrive in an hour, or how long a project might take — use RANDBETWEEN() to generate random values within realistic ranges, then build calculations on top of them. Run the spreadsheet multiple times (pressing F9 each time) to see the range of possible outcomes.
For testing, use RANDBETWEEN() to fill a spreadsheet with fake data that looks realistic. This is faster than typing test data by hand and helps you catch errors in your formulas before you use them on real data.
Frequently Asked Questions
Can I make random numbers that do not change when I edit other cells?
Yes. Copy the cells with random formulas, then use Paste Special and choose Values. This replaces the formulas with fixed numbers that will not recalculate. You can also press Ctrl+Shift+F9 to recalculate only the current sheet instead of the whole workbook, which gives you more control.
What is the difference between RAND() and RANDBETWEEN()?
RAND() produces decimals between 0 and 1. RANDBETWEEN() produces whole numbers within a range you specify, like 1 to 100. Use RAND() when you need decimals or want to scale the output yourself; use RANDBETWEEN() when you need whole numbers in a specific range.
Does RANDARRAY() work in older versions of Excel?
No. RANDARRAY() only works in Excel 365 and Excel 2021 or later. If you have an older version and see a #NAME? error, use RAND() or RANDBETWEEN() in a single cell and copy it down and across instead.
How do I generate random numbers without decimals using RAND()?
Wrap RAND() in the INT() function: =INT(RAND()*100) gives you a random whole number between 0 and 99. This is more work than RANDBETWEEN(), so use RANDBETWEEN() instead unless you have a specific reason to use RAND().
Can I set a seed so the same random numbers appear every time?
Excel does not have a built-in seed function like some other tools do. If you need reproducible random numbers, generate them once, convert them to values, and save the file. Or use a different tool like Python or R that supports seeding.