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.
Syntax
| Argument | Description | |
|---|---|---|
bottom | Required | The smallest integer RANDBETWEEN can return. |
top | Required | The 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.
Both bounds can be negative, so you can generate values on either side of zero:
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
Pick a RANDBETWEEN example to see the formula and its result.
Practice workbook
Frequently asked questions
Are both bounds included in the result?
=RANDBETWEEN(1,6) can return 1, 6, or anything between — both the bottom and top values are possible.Does RANDBETWEEN return whole numbers only?
RAND and scale it, e.g. a+RAND()*(b-a).Can the bounds be negative?
=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?
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