
Returns a random integer between two specified bounds. RANDBETWEEN is useful for discrete simulations, test datasets, and randomized indexing.
The Excel RANDBETWEEN function returns a random integer between a lower bound and an upper bound. Microsoft documents that both endpoints are inclusive, which means the bottom and top values themselves can appear in the result. Like RAND, the function is volatile and recalculates whenever the worksheet recalculates.
RANDBETWEEN is designed for discrete outcomes rather than continuous ones. That distinction matters. If the model requires whole numbers such as random IDs, simulated die rolls, random day counts, or row-selection indexes, RANDBETWEEN is usually more direct than building the same behavior from RAND and rounding functions.
Returns a whole number between the specified bottom and top values, including both endpoints.
Returns an integer that changes on recalculation. If bottom is greater than top, Excel returns #NUM!.
=RANDBETWEEN(bottom, top)
RANDBETWEEN requires two arguments. bottom is the smallest possible integer and top is the largest possible integer. Both values can be typed directly or referenced from cells. The function is simpler than an equivalent INT(RAND()*...) pattern when the requirement is plainly "return an integer between these two bounds."
RANDBETWEEN and RAND often appear together in training material, but they serve different worksheet needs. The distinction is not about randomness itself; it is about the shape of the output.
| Function | Output | Use When |
|---|---|---|
RANDBETWEEN |
Discrete integer | You need a whole-number draw between two stated bounds |
RAND |
Continuous decimal from 0 to less than 1 | You need a decimal draw or want to scale the interval yourself |
RANDARRAY |
Spilled range of random values | You need many random values at once in Excel 365 |
If decimal precision is required, RANDBETWEEN is usually not the right starting point. In that case, either use RAND directly or generate scaled integers and divide them afterward only if a fixed decimal precision is acceptable.
RANDBETWEEN is common in temporary data generation because many test scenarios need realistic whole-number values such as counts, scores, rankings, or IDs. It is also useful in discrete simulations where the possible outcomes are countable rather than continuous.
Because the function recalculates automatically, it should be handled with the same care as RAND in finished workbooks. If the random outputs are meant to become fixed sample data, they should be copied and pasted as values after generation. Otherwise, unrelated sheet edits can change every simulated result.
This example shows the standard behavior directly. Any integer between 1 and 100 can appear, and both endpoints are valid outcomes. That inclusive behavior is an important difference from RAND, whose upper limit is never actually reached.
=RANDBETWEEN(1,100)
// Possible results: 1 through 100
In cell F1, use RANDBETWEEN to get a random whole number from 1 to 100. Expected: any integer from 1 to 100.
A six-sided die is a discrete model with six equally valid integer outcomes. RANDBETWEEN maps directly onto that structure, which makes the formula readable and mathematically aligned with the scenario.
=RANDBETWEEN(1,6)
// Possible results: 1, 2, 3, 4, 5, or 6
In cell F2, use RANDBETWEEN to simulate a dice roll - a random integer from 1 to 6.
Using cell references makes the formula reusable. If the lower or upper limit changes, the model can be adjusted by editing the bounds rather than rewriting the formula itself. That is especially useful in scenario testing.
=RANDBETWEEN(B1,C1)
// B1 = 50, C1 = 200
// Result is an integer from 50 through 200
In cell F3, use RANDBETWEEN with the bottom from B1 (50) and top from C1 (200). Expected: any integer between 50 and 200.
Negative and mixed-sign ranges are valid. This is useful in models that simulate gains and losses, temperature variation, or any centered distribution where zero is not the only meaningful reference point.
=RANDBETWEEN(-10,10)
// Possible results: -10 through 10
In cell F4, use RANDBETWEEN(-10,10) to get a random integer from -10 to 10 inclusive.
One practical caution is bound ordering. If the lower bound exceeds the upper bound, Excel returns #NUM! instead of attempting to infer the intended direction. That is usually desirable because it exposes invalid input immediately rather than hiding it.
RANDBETWEEN returns a random integer between two inclusive bounds.=RANDBETWEEN(bottom,top).#NUM! when bottom is greater than top.Tell your friends about this post