Templates, guides & honest tool reviews for small business

Monday, November 30, 2026

Random Number Generator in Excel: RANDBETWEEN and RANDARRAY

Section: Excel & Google Sheets

Random Number Generator in Excel - explanatory illustration for Random Number Generator in Excel
Illustration: Random Number Generator in Excel

To make a random number generator in Excel, type =RANDBETWEEN(1,100) and press Enter. You get a whole number from 1 to 100, and a new one every time the sheet recalculates. This guide covers RANDBETWEEN, RANDARRAY and RAND, how to generate random numbers in Excel without duplicates getting in the way, how to stop random numbers from changing, and how to roll dice or pick a sample for a draw. The examples use made-up numbers.

RANDBETWEEN: random whole numbers

Microsoft describes RANDBETWEEN as returning a random integer between the numbers you specify. The syntax is =RANDBETWEEN(bottom, top), and both arguments are required. Bottom is the smallest integer it can return and top is the largest.

Microsoft's own examples are =RANDBETWEEN(1,100) and =RANDBETWEEN(-1,1). The second one can return -1, 0 or 1, so negative bottoms work. Both ends are included, which is why =RANDBETWEEN(1,6) works as a die.

RANDBETWEEN at a glance - explanatory illustration for Random Number Generator in Excel
RANDBETWEEN at a glance (explanatory illustration, not a software screenshot).

Why the numbers keep changing

A new random integer is returned every time the worksheet is calculated. Microsoft's note says that entering a formula or data in a different cell, or pressing F9 to recalculate, generates a new random number for every RANDBETWEEN formula. That surprises people who type a value into a nearby cell and watch a whole column of random numbers change.

This is the same behaviour as TODAY and NOW, which also recalculate. Treat any random formula as volatile and expect it to move.

Keep the numbers fixed

When you need a result to stay put, such as a draw you have already announced, convert it to values. Select the random cells, copy them, then use Paste Special and choose Values. The formulas are replaced with the numbers they showed, and nothing changes after that.

Do this before you send the file. A random column left as formulas will show different numbers to everyone who opens it.

RANDARRAY: many numbers from one formula

RANDARRAY returns a whole array of random numbers from one formula. The syntax is =RANDARRAY([rows],[columns],[min],[max],[whole_number]), and every argument is optional.

  • With no arguments it returns one decimal between 0 and 1.
  • Minimum and maximum default to 0 and 1.
  • Whole_number defaults to FALSE, so you get decimals unless you ask for whole numbers with TRUE.
  • The minimum must be less than the maximum, or you get a #VALUE! error.

So =RANDARRAY(5,3,1,100,TRUE) returns a block of whole numbers between 1 and 100 that is 5 rows tall and 3 columns wide. The result spills, so the cells it needs must be empty. If they are not, see how dynamic array functions such as SEQUENCE spill.

Microsoft lists RANDARRAY for Microsoft 365, Excel 2024 and Excel 2021, and also for the iPad, iPhone and Android apps. RANDBETWEEN also works in Excel 2019 and Excel 2016, so use it if your file has to open in an older version.

RANDARRAY arguments and defaults - explanatory illustration for Random Number Generator in Excel
RANDARRAY arguments and defaults (explanatory illustration, not a software screenshot).

RAND for decimals in a range

RAND returns a decimal between 0 and 1, and Microsoft's RANDARRAY page notes that RAND does not return an array, so it has to be copied down the range. To get a decimal between two numbers, scale it: =RAND()*(b-a)+a. For a value between 10 and 20, that is =RAND()*10+10.

Roll dice and run a draw

One die is =RANDBETWEEN(1,6). Two dice are the sum of two of them. There are 36 combinations, and 6 of them make a total of 7, so the chance of a 7 is 6 out of 36, or 16.67%. Run a few hundred rolls and the share of sevens should land near that figure, though never exactly on it.

For a prize draw, number your entries and use =RANDBETWEEN(1,150) for 150 entries. Paste the result as a value as soon as you have it, so the winner does not change on the next recalculation.

Two dice and the total of 7 - explanatory illustration for Random Number Generator in Excel
Two dice and the total of 7 (explanatory illustration, not a software screenshot).

The duplicate problem

RANDBETWEEN does not promise unique numbers. If you ask for ten values between 1 and 100, the chance that at least two match is about 37.2%. Worked out, that is 1 minus (100 x 99 x 98 ... x 91) divided by 100 to the power of 10.

If you need a sample with no repeats, generate more numbers than you need, then remove the repeats with UNIQUE and keep the first rows you need.

Common problems

  • The numbers change on their own. Excel recalculated. Paste as values to freeze them.
  • #VALUE! from RANDARRAY. The minimum is not lower than the maximum.
  • #NAME? error. RANDARRAY is not in your Excel version. Use RANDBETWEEN.
  • #SPILL! error. Something blocks the cells below or beside the formula.
  • Duplicates in the list. Random does not mean unique. Use UNIQUE or draw extra.
  • Decimals when you wanted whole numbers. Set the last RANDARRAY argument to TRUE.
Common problems with random numbers - explanatory illustration for Random Number Generator in Excel
Common problems with random numbers (explanatory illustration, not a software screenshot).

Questions and answers

How do I generate a random number between two numbers in Excel?

Use =RANDBETWEEN(bottom, top). Both ends are included.

How do I stop random numbers from changing?

Copy them and paste as values. You can also switch calculation to manual, but then everything else stops updating too.

What is the difference between RAND and RANDBETWEEN?

RAND returns a decimal between 0 and 1. RANDBETWEEN returns a whole number between two limits you choose.

Can RANDBETWEEN return a decimal?

No, it returns integers. Use RAND with scaling or RANDARRAY with FALSE for decimals.

Are Excel random numbers truly random?

They are fine for games, samples and drafts. Do not use them where security matters.

Official references

العربية