Excel can generate random numbers with two built-in functions: RAND() returns a decimal between 0 and 1, and RANDBETWEEN(bottom, top) returns a whole number inside a range you set. Both are volatile, which means they recalculate every time the sheet changes — and that is the one detail that trips most people up. Knowing how to freeze the results is the difference between a usable random sample and numbers that shuffle themselves while you work. Nothing needs installing; any modern desktop version of Excel (Windows or Mac) and Excel for the web include both functions. The examples below use the standard English function names, and menu or ribbon labels can differ slightly by version and region.
What You'll Need
- A spreadsheet open in Excel for Windows, Mac, or the web.
- An empty column or cell range to hold your formulas.
- A clear idea of your range: decimals from 0 to 1, whole numbers between two values, or a random pick from an existing list.
- Optional but recommended: a blank helper column where you will paste values once the numbers are fixed.
Step-by-Step
- Pick the right function. Use
=RAND()when you want a decimal probability (useful for simulations, weights, or percentages). Use=RANDBETWEEN(1,100)when you want whole numbers, such as rolling a die with=RANDBETWEEN(1,6)or picking a lottery-style number between 1 and 49. - Enter the formula in one cell. Click a cell, type the formula, and press Enter. Include the parentheses even when RAND has no arguments — typing
=RANDalone is accepted by recent versions but=RAND()is the safe form. The result appears immediately. - Fill it down the column. Select the cell, then drag the small square at its bottom-right corner (the fill handle) down as far as you need. Alternatively, copy the cell, select the target range, and paste. For 50 random values, fill 50 rows.
- Lock the range with absolute references if needed. If your bottom and top limits live in separate cells — say B1 holds 1 and B2 holds 999 — write
=RANDBETWEEN($B$1,$B$2)so the fill-down does not shift the reference and produce a #NUM! error. - Round RAND to a set number of decimals. RAND gives roughly 15 decimal places. Wrap it:
=ROUND(RAND(),2)for two decimals, or=ROUND(RAND()*100,0)for a whole number from 0 to 100. For a decimal between two limits, use=RAND()*(top-bottom)+bottom. - Freeze the numbers before you use them. Because these functions recalculate on any edit, select the whole range, press Ctrl+C (Cmd+C on Mac), then right-click and choose Paste Special > Values. You now have static numbers. This step is essential for anything you plan to sort, print, or compare later.
- Generate a random sample from a list. Put your items in column A. In column B, fill
=RAND()down beside each one. Select both columns, go to Data > Sort, and sort by column B smallest to largest. The first N rows of column A are now a random sample. Delete column B when you are done, since it serves only to shuffle the order. - Pick a random item directly. For a short list,
=INDEX(A1:A10,RANDBETWEEN(1,10))returns one random entry. For a list of unknown length, use=INDEX(A:A,RANDBETWEEN(1,COUNTA(A:A))), assuming column A has no blank rows in the middle. - Generate unique numbers without repeats. RANDBETWEEN can and will repeat. To draw unique values, add a RAND column beside each candidate, sort by it, and take the top N — that guarantees no duplicates. A formula trick with
=RAND()and ranking works too, but the sort method is easier to verify by eye. - Check the recalculation setting. Go to File > Options > Formulas (on Mac: Excel > Preferences > Calculation) and confirm Automatic is selected. If the workbook is set to Manual, your formulas will not refresh until you press F9, which makes it look as though RAND is broken.
Common Mistakes
- Not freezing the values. This is the number one problem. Sort, format, or edit one cell and every random number changes, silently destroying a sample you already labelled or recorded.
- Expecting RAND to stay the same. RAND is volatile by design. If you need reproducibility, paste values or use a fixed table of numbers instead.
- Forgetting the parentheses.
=RANDBETWEENwithout arguments returns a #VALUE! or #NUM! error. - Reversing the limits. RANDBETWEEN needs bottom less than top.
=RANDBETWEEN(10,1)fails with #NUM!. - Using RAND for a lottery assumption. RAND is a pseudo-random function intended for simulations and sampling, not for cryptography, gambling, or anything security-sensitive. Use a dedicated random source for those.
- Copying the same value instead of a formula. Pasting a range normally is fine, but if you paste a value into several cells at once with Paste Special > Values, every cell gets the identical number. Fill first, then freeze.
Tips
- Press F9 to force a manual recalculation of the whole sheet; Shift+F9 recalculates just the active sheet.
- To simulate a coin flip, use
=IF(RANDBETWEEN(0,1)=1,"Heads","Tails"). - For weighted picks, multiply RAND by the total weight and use a lookup table of cumulative ranges.
- Keep a separate "frozen" sheet with pasted values and a "live" sheet with formulas so you can rerun a draw without losing the previous result.
- If you need many random numbers for statistical work, fill one column and paste values rather than 10,000 volatile formulas, which slow large workbooks down considerably.
Troubleshooting
Numbers change when you click elsewhere. This is expected volatility. Select the range and Paste Special > Values to lock it.
You see #NUM! in RANDBETWEEN. Check that the bottom value is smaller than the top, and that both are numbers, not text. Values in quotes like "1" are treated as text and will fail.
You see #VALUE!. A limit cell is probably blank or holds text. Clear it or replace it with a real number.
The formula shows as text. The cell is formatted as Text. Change the format to General, then re-enter the formula — editing the format alone will not convert an existing text entry.
Formulas will not recalculate at all. Check the calculation mode under File > Options > Formulas and set it to Automatic, then press F9.
You get duplicates. RANDBETWEEN samples with replacement. Sort a RAND column as described above to get unique draws.
Frequently Asked Questions
How do I stop Excel random numbers from changing?
Copy the cells, then Paste Special > Values. That replaces the live formula with a fixed number.
Is RAND truly random?
No. It is pseudo-random and fine for simulations and sampling, but not suitable for cryptography or security tokens.
Can I generate random numbers without duplicates in one formula?
Not with RANDBETWEEN alone. Add a RAND helper column, sort by it, and take the number of rows you need.
How do I get a random decimal between two values?
Use =RAND()*(top-bottom)+bottom, for example =RAND()*(10-5)+5 for a value between 5 and 10.
Why does RANDBETWEEN skip the top number?
It does not — RANDBETWEEN includes both the bottom and top values. If a number seems missing, you are probably looking at a stale value that has not recalculated or was overwritten by a paste.
Does RAND work in Excel for the web and Google Sheets?
Yes. Excel for the web supports both functions, and Google Sheets has the same two functions with identical syntax.