Excel has two built-in functions that generate random numbers

The easiest way to create a random number generator in Excel is to use either the RAND() function or the RANDBETWEEN() function. RAND() produces a decimal number between 0 and 1. RANDBETWEEN() lets you specify a range — for example, random whole numbers between 1 and 100. Both recalculate every time your spreadsheet updates, so the numbers change constantly unless you lock them in place.

Which function you use depends on what you need. If you want decimals for calculations or probabilities, use RAND(). If you want whole numbers within a specific range — like simulating dice rolls or picking random entries from a list — use RANDBETWEEN().

Key Takeaways

  • RAND() generates a random decimal between 0 and 1; RANDBETWEEN() generates a random whole number within a range you specify.
  • Type =RAND() in any cell to start, or =RANDBETWEEN(1,100) to get a number between 1 and 100.
  • Random numbers recalculate every time Excel updates, so copy and paste as values if you need numbers that stay the same.
  • You can combine RANDBETWEEN() with other functions to shuffle lists, pick random items, or simulate real-world scenarios.

Using RAND() for decimal numbers between 0 and 1

Click on any empty cell and type =RAND(), then press Enter. Excel fills that cell with a random decimal number. The number will have many digits after the decimal point — something like 0.7429384. If you want fewer decimal places, right-click the cell, select Format Cells, choose Number, and set the decimal places to however many you want to see.

RAND() has no arguments — you don't put anything inside the parentheses. Every time your spreadsheet recalculates (which happens when you edit any cell, open the file, or press F9), RAND() generates a brand new random number. This makes it useful for simulations, probability models, or any calculation where you need a fresh random value each time.

If you need the same random numbers to stay put, select the cells with RAND() formulas, copy them, then right-click and choose Paste Special. Click Values Only and press OK. This replaces the formulas with the numbers they produced, so they no longer change.

Using RANDBETWEEN() for whole numbers in a specific range

Click on an empty cell and type =RANDBETWEEN(1,100), then press Enter. Replace 1 and 100 with whatever range you want. This generates a random whole number between those two numbers, including both endpoints. So RANDBETWEEN(1,100) can produce 1, 100, or anything in between — never a decimal.

The syntax is always =RANDBETWEEN(lowest, highest). If you want to simulate a six-sided die, type =RANDBETWEEN(1,6). For a coin flip represented as 0 or 1, type =RANDBETWEEN(0,1). The lowest number must come first, or Excel shows an error.

Like RAND(), RANDBETWEEN() recalculates every time the spreadsheet updates. If you need the numbers to stay constant, copy the cells, then Paste Special as Values Only to lock them in.

Locking random numbers so they don't change

By default, random numbers regenerate whenever Excel recalculates. If you want numbers that stay the same, you must convert the formulas to values. Select the cells containing your random numbers, press Ctrl+C to copy, then right-click and choose Paste Special. In the dialog box, click the Values Only radio button and press OK. The formulas disappear and become fixed numbers.

This is the only way to preserve random numbers. If you leave them as formulas, they will change the next time you edit the spreadsheet, press F9, or close and reopen the file. Many people forget this step and lose their original random values — convert to values as soon as you have the numbers you want to keep.

Combining random numbers with other functions

You can use RANDBETWEEN() inside other functions to build more complex tools. For example, to pick a random item from a list in cells A1 through A10, type =INDEX(A1:A10,RANDBETWEEN(1,10)). This generates a random number between 1 and 10, then uses that number to pick the corresponding item from your list.

To shuffle a list, add a helper column next to your data with =RAND() in each row, then sort the entire table by that helper column. The random numbers will reorder your list in random order. Once sorted, convert the helper column to values so the order stays put, then delete the helper column.

You can also use RANDBETWEEN() to simulate real scenarios. To model 100 coin flips, create a column with =RANDBETWEEN(0,1) repeated 100 times, where 0 is tails and 1 is heads. To roll two dice and add them, type =RANDBETWEEN(1,6)+RANDBETWEEN(1,6). These combinations let you run simulations and test probability without writing code.

Controlling when random numbers recalculate

If random numbers recalculating constantly bothers you, you can change Excel's calculation mode. Click the Formulas tab, then click Calculation Options and choose Manual. Now Excel only recalculates when you press F9 or Ctrl+Shift+F9, not every time you edit a cell. This gives you control over when your random numbers change.

Be careful with Manual mode — it affects all formulas in your spreadsheet, not just random ones. Other calculations may appear outdated until you press F9. Most people leave calculation on Automatic and just convert random formulas to values when they need numbers that stay still.

Common mistakes and how to avoid them

The most common mistake is forgetting that random numbers change constantly. You generate numbers, close the file, reopen it, and they are different. If you need to preserve specific random values, convert them to values immediately using Paste Special. Do not wait — you will lose them the moment you edit the spreadsheet.

Another mistake is using the wrong function for your goal. RAND() produces decimals, so if you type =RAND() expecting a whole number between 1 and 10, you will get 0.something instead. Use RANDBETWEEN() when you need whole numbers. If you need decimals in a specific range — say, between 1 and 10 — multiply RAND() by 9 and add 1: =RAND()*9+1.

A third mistake is putting the lowest number second in RANDBETWEEN(). The syntax is =RANDBETWEEN(lowest, highest). If you reverse them, Excel returns an error. Always put the smaller number first.

Frequently Asked Questions

Can I generate random numbers without them changing every time I edit the spreadsheet?

Yes. Select the cells with random formulas, copy them, right-click, choose Paste Special, click Values Only, and press OK. This converts the formulas to fixed numbers that never change. You can also switch Excel to Manual calculation mode so formulas only recalculate when you press F9.

How do I generate a random decimal between two numbers, like 5.5 and 10.5?

Use the formula =RAND()*(highest-lowest)+lowest. For 5.5 to 10.5, type =RAND()*(10.5-5.5)+5.5. This multiplies a random decimal by the range size, then adds the lowest number to shift it into the range you want.

What is the difference between RAND() and RANDBETWEEN()?

RAND() produces random decimals between 0 and 1. RANDBETWEEN() produces random whole numbers within a range you specify. Use RAND() for calculations and probabilities; use RANDBETWEEN() for simulations, dice rolls, or picking random items from a list.

Can I use random numbers to pick a random name from a list?

Yes. If your names are in cells A1 through A20, type =INDEX(A1:A20,RANDBETWEEN(1,20)). This generates a random number between 1 and 20, then uses it to pick the corresponding name. The formula picks a new name every time the spreadsheet recalculates.

Why does my RANDBETWEEN() formula show an error?

The most common cause is reversing the order of the numbers. RANDBETWEEN() requires the lowest number first: =RANDBETWEEN(lowest, highest). If you type =RANDBETWEEN(100,1), Excel returns an error. Also check that both numbers are whole numbers — decimals inside RANDBETWEEN() cause errors.