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 between the two values you specify. Type either formula into a cell and press Enter, and Excel fills the cell with a random value. That is the short answer. The longer answer — how to get a fixed set of numbers that does not change every time you edit the sheet, how to pick random names from a list, how to avoid duplicates, and how to stop the numbers from recalculating — is what the rest of this guide covers.

What You'll Need

  • Excel for Microsoft 365, Excel 2021, Excel 2019, or Excel for Mac. The functions described here also work in Excel for the web and in Excel for iPad/iPhone and Android, though the menu labels differ slightly by version, device and region.
  • A workbook with at least one empty column where the random numbers will go.
  • Optional: a list of names or items if you want to pick a random sample from existing data.

Step-by-Step

  1. Open the workbook and click the cell where you want the first random number. Pick an empty column so you do not overwrite existing data.
  2. For a decimal between 0 and 1, type =RAND() and press Enter. The cell shows a number like 0.472831. The parentheses are required even though the function takes no arguments.
  3. For a whole number in a range, type =RANDBETWEEN(1, 100) and press Enter. Replace 1 and 100 with your own lower and upper bounds. Both bounds are inclusive, so RANDBETWEEN(1, 100) can return 1 or 100.
  4. Copy the formula down the column. Click the cell, grab the small square at the bottom-right corner (the fill handle), and drag down as many rows as you need. Each row gets its own independent random value.
  5. Freeze the results before you rely on them. RAND and RANDBETWEEN are volatile: they recalculate every time the sheet recalculates, which happens on any edit, on open, and on F9. To lock the numbers in place, select the cells, press Ctrl+C (Cmd+C on Mac), then right-click and choose Paste Special > Values. The formulas are replaced by their current results.
  6. To pick a random name from a list, combine RANDBETWEEN with INDEX. If names are in A2:A20, use =INDEX(A2:A20, RANDBETWEEN(1, 19)). The 19 is the count of rows in the list; adjust it to match your range.
  7. To pick several names without duplicates, use a helper column. In B2 put =RAND() and fill down beside every name. Then select both columns, go to the Data tab, and click Sort. Sort by the random column, smallest to largest. The top N rows of the sorted list are your random sample with no repeats. Delete the helper column afterwards.
  8. To generate a random decimal in a custom range, scale RAND. The formula =RAND()*(max-min)+min returns a decimal between min and max. For example, =RAND()*50+10 gives a value from 10 up to (but not including) 60.

Common Mistakes

  • Expecting the numbers to stay put. New users often build a random sample, then edit another cell and watch every number change. Always paste as values once the sample is final.
  • Forgetting that RANDBETWEEN includes both ends. If you want numbers 1 through 10 but type RANDBETWEEN(1, 9), you will never see a 10.
  • Using RAND for whole numbers. RAND returns decimals only. Wrap it in ROUND or INT if you need integers, or just use RANDBETWEEN.
  • Sorting only one column. When you sort to shuffle a list, select the whole table first. Sorting a single column breaks the link between names and any data beside them.
  • Assuming RANDBETWEEN is truly random. It is pseudo-random and fine for sampling, games and draft picks, but it is not suitable for cryptography, passwords or security tokens.
  • Leaving volatile formulas in a large workbook. Hundreds of RAND formulas recalculate on every keystroke and can slow a big sheet noticeably. Convert them to values when you are done.

Tips

  • Press F9 to force a recalculation and get a fresh set of random numbers without editing anything.
  • Use =RANDARRAY(rows, columns, min, max, whole_number) in Microsoft 365 to fill a block of random values in one step. The last argument TRUE gives whole numbers; FALSE gives decimals. This function is not available in older Excel versions.
  • To generate random dates, use =RANDBETWEEN(DATE(2024,1,1), DATE(2024,12,31)) and format the cell as a date.
  • If you need a repeatable sequence for testing, RANDBETWEEN is not the right tool — it has no seed argument. Paste as values once and reuse that fixed set.
  • Keep a copy of the frozen values on a separate sheet so a later sort or filter does not disturb the original sample.

Troubleshooting

  • The formula shows as text instead of a result. The cell is probably formatted as Text. Select it, go to Home > Number Format, choose General, then re-enter the formula (press F2, then Enter).
  • You see #NAME?. The function name is misspelled or the workbook is in an older format. Check the spelling and confirm you are using a version that supports the function.
  • You see #VALUE!. One of the arguments is not a number. RANDBETWEEN needs numeric bounds, not text.
  • Numbers keep changing when you do not want them to. You are still looking at live formulas. Paste as values as described in step 5.
  • RANDARRAY is not recognised. Your Excel version does not support dynamic arrays. Use RAND or RANDBETWEEN and fill down instead.
  • The random pick seems biased. Check that your INDEX range and the RANDBETWEEN upper bound match the actual number of items. An off-by-one range silently excludes the last item.

Frequently Asked Questions

What is the difference between RAND and RANDBETWEEN?

RAND returns a decimal from 0 up to but not including 1. RANDBETWEEN returns a whole number between two bounds you set, and both bounds are included.

How do I stop random numbers from changing?

Copy the cells, then use Paste Special > Values. This replaces the formulas with their current results, which no longer recalculate.

Can I pick random names without duplicates?

Yes. Add a column of =RAND() beside the names, sort the whole table by that column, and take the top rows you need. Delete the helper column afterwards.

Is RANDBETWEEN suitable for passwords or security codes?

No. It is a pseudo-random generator intended for sampling and modelling, not for security purposes.

Why does my random number change when I open the file?

Volatile functions recalculate on open. Paste as values before saving if you need the numbers to stay fixed.

Can I generate random numbers on Excel for the web or mobile?

Yes, RAND and RANDBETWEEN work in Excel for the web and in the mobile apps. Menu labels for Paste Special and Sort vary slightly by version and device.