RANDBETWEEN Function

Excel Functions › Math & Trig

All versions Math & Trig

The Excel RANDBETWEEN function returns a random whole number between two bounds you specify (inclusive), regenerating on every recalculation — perfect for dice rolls, sample IDs, and test data.


Quick answer:
=RANDBETWEEN(1, 6) a random whole number from 1 to 6 (a die roll)

Syntax

=RANDBETWEEN(bottom, top)
ArgumentDescription
bottomRequiredThe smallest integer RANDBETWEEN can return.
topRequiredThe largest integer RANDBETWEEN can return. Must be greater than or equal to bottom.

How to use it

RANDBETWEEN returns a random integer from bottom to top, both ends included. Like RAND, it is volatile and recalculates on every change or F9.

=RANDBETWEEN(1, 6) // random 1-6, like a die
=RANDBETWEEN(1, 100) // random 1-100

Both bounds can be negative, so you can generate values on either side of zero:

=RANDBETWEEN(-10, 10)// random integer from -10 to 10

For random decimals use RAND; to spill a whole array of random numbers at once (Excel 365) use RANDARRAY.

Volatile: the value changes on every recalculation. Copy and Paste Special > Values to freeze a result.

Try it: interactive demo

Live demo

Pick a RANDBETWEEN example to see the formula and its result.

Result:

Practice workbook

📊
Download the free RANDBETWEEN practice workbook
Every example on this page, ready to open in Excel — plus practice challenges with answers on a separate tab. No sign-up required.

Frequently asked questions

Are both bounds included in the result?
Yes. =RANDBETWEEN(1,6) can return 1, 6, or anything between — both the bottom and top values are possible.
Does RANDBETWEEN return whole numbers only?
By default yes — it returns integers. For random decimals, use RAND and scale it, e.g. a+RAND()*(b-a).
Can the bounds be negative?
Yes. =RANDBETWEEN(-10,10) returns a random integer from -10 to 10. Just make sure top is greater than or equal to bottom.
Why does the number keep changing?
RANDBETWEEN is volatile and recalculates on every workbook change or when you press F9. Use Paste Special > Values to keep a fixed result.

Master functions like this in one day

This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related functions: RAND · RANDARRAY · SEQUENCE · INT · ROUND