Excel has three functions that create random numbers, and which one you use depends on whether you need decimals, whole numbers, or a specific range

RAND() generates a decimal between 0 and 1. RANDBETWEEN() generates a whole number within a range you set. RANDARRAY() fills multiple cells at once with random numbers. All three recalculate every time the spreadsheet changes — if that's a problem for your work, you'll need to convert the results to static values afterward.

The function you pick depends on what your data needs. If you're testing a model with decimal values, RAND() is fastest. If you need whole numbers like dice rolls or ID numbers, RANDBETWEEN() saves you a step. If you're filling a large table, RANDARRAY() is built for that job.

Key Takeaways

  • RAND() produces decimals between 0 and 1; multiply the result by a number to shift the range (for example, =RAND()*100 gives 0 to 100).
  • RANDBETWEEN(bottom, top) creates whole numbers within your chosen range and is the simplest choice for most everyday tasks.
  • RANDARRAY() fills a block of cells with random numbers in one formula, which is faster than copying a formula down hundreds of rows.
  • All three functions recalculate when the spreadsheet recalculates, so save a copy before converting random numbers to fixed values if you need them to stay the same.

Using RAND() for decimals between 0 and 1

RAND() is the simplest function: type =RAND() in a cell and it returns a decimal like 0.472 or 0.891. Every time Excel recalculates, it picks a new number. The function takes no arguments — the parentheses are always empty.

To shift the range, multiply the result. =RAND()*100 gives you 0 to 100. =RAND()*10 gives 0 to 10. If you need a range that doesn't start at zero, add a number after multiplying: =RAND()*50+50 gives 50 to 100. The formula =RAND()*20-10 gives -10 to 10.

RAND() is useful for simulations, testing formulas with sample data, or any task where you need many decimal values fast. The downside is that it recalculates constantly — if you close and reopen the file, the numbers change.

Using RANDBETWEEN() for whole numbers in a specific range

RANDBETWEEN(bottom, top) creates a whole number between two values you specify. Type =RANDBETWEEN(1,100) to get a number from 1 to 100. Type =RANDBETWEEN(1,6) to simulate a die roll. The bottom number and top number are both included in the possible results.

This function is the most common choice because it requires no math. You set the range once and the formula does the rest. It works in all versions of Excel and in Google Sheets, so it's reliable across platforms.

Like RAND(), RANDBETWEEN() recalculates every time the spreadsheet updates. If you need the numbers to stay fixed, copy the cells, then use Paste Special and choose Values Only to replace the formulas with the numbers they produced.

Using RANDARRAY() to fill multiple cells at once

RANDARRAY() fills a block of cells with random numbers in a single formula. This function is newer — it works in Excel 2021 and Microsoft 365, but not in older versions. Type =RANDARRAY(5,3) to fill 5 rows and 3 columns with decimals between 0 and 1.

To set a range, add minimum and maximum values: =RANDARRAY(5,3,1,100) fills 5 rows and 3 columns with whole numbers from 1 to 100. The order is always: rows, columns, minimum, maximum. If you leave out the minimum and maximum, you get decimals between 0 and 1.

RANDARRAY() saves time when you're building a large test dataset. Instead of typing a formula in one cell and copying it down, you enter one formula and it expands to fill the space you need. The results still recalculate with the spreadsheet, so convert them to values if you need them to stay the same.

Converting random numbers to fixed values

Random functions recalculate whenever Excel recalculates — when you edit a cell, open the file, or press F9. If you need the numbers to stay the same, convert them to values. Select the cells with the random numbers, copy them, then right-click and choose Paste Special. Select Values and click OK. The formulas turn into the numbers they produced, and they no longer change.

This is important if you're sharing a file with others or if you're using the random numbers as part of a permanent record. Without this step, anyone who opens the file or makes an edit will see different numbers.

Controlling when random numbers recalculate

By default, Excel recalculates all formulas whenever you make a change. If you have many random functions and the constant recalculation is slowing you down, you can switch to manual calculation. Go to Formulas > Calculation Options > Manual. Now the random numbers only change when you press Ctrl+Shift+F9 (or Cmd+Shift+F9 on Mac). Press F9 to recalculate only the current sheet.

Manual calculation is useful when you're building a large spreadsheet and don't want every keystroke to trigger a recalculation. Remember to switch back to Automatic when you're done, or you may forget that your formulas aren't updating.

Common uses for random numbers in Excel

Random numbers are useful for testing. If you're building a budget model, you can use RANDBETWEEN() to simulate different income levels and see how the rest of the spreadsheet responds. If you're checking whether a formula works correctly, random test data is faster than typing sample numbers by hand.

They're also used for sampling and randomization. If you have a list of names and want to pick a few at random, you can add a column of random numbers next to the names, sort by the random column, and take the top few rows. For games, quizzes, or any task that needs unpredictable results, RANDBETWEEN() is the standard choice.

Frequently Asked Questions

Why do my random numbers keep changing?

All three random functions recalculate whenever Excel recalculates — which happens when you edit a cell, open the file, or press F9. If you need the numbers to stay the same, select them, copy, then Paste Special > Values to replace the formulas with the numbers they produced.

Can I generate random numbers without decimals?

Yes. Use RANDBETWEEN(bottom, top) for whole numbers, or use =INT(RAND()*number) to round down a decimal result. RANDBETWEEN() is simpler and more reliable for this task.

What's the difference between RAND() and RANDBETWEEN()?

RAND() produces decimals between 0 and 1 and requires math to shift the range. RANDBETWEEN() produces whole numbers within a range you specify and requires no math. Use RANDBETWEEN() for most everyday tasks.

Does RANDARRAY() work in Google Sheets?

No. RANDARRAY() is specific to Excel 2021 and Microsoft 365. Google Sheets has RAND() and RANDBETWEEN(), but not RANDARRAY(). If you need to fill many cells at once in Google Sheets, copy a RANDBETWEEN() formula down the column.

Can I set a seed so the same random numbers appear every time?

Excel's random functions don't have a seed option. If you need reproducible random numbers, you'll need to convert them to values and save them, or use a different tool like Python or R that supports seeding.