RANDBETWEEN Function
RANDBETWEEN Function

RANDBETWEEN Function

Returns a random integer between two specified bounds. RANDBETWEEN is useful for discrete simulations, test datasets, and randomized indexing.

ExcelClash Team
PUBLISHED

Summary

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.

RANDBETWEEN is useful when random output must stay inside a clear boundary. That makes it practical for demos, assignments, mock IDs, and controlled simulations where the workbook should generate values unpredictably but still inside an allowed range.

Purpose

Generate a random integer in a range

Returns a whole number between the specified bottom and top values, including both endpoints.

Return Value

A random whole number

Returns an integer that changes on recalculation. If bottom is greater than top, Excel returns #NUM!.

Syntax

=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."

Arguments

  • bottom - [Required] The minimum integer that can be returned.
  • top - [Required] The maximum integer that can be returned.

RANDBETWEEN vs Related Functions

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.

Using RANDBETWEEN

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.

  • Use RANDBETWEEN for discrete random values.
  • Use cell references for bounds when scenarios change often.
  • Freeze the results if the random sample should stop changing.

Example 1 - Generate a Random Integer from 1 to 100

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.

This is a useful starting example because it shows the exact kind of output the function is built for: whole numbers inside a fixed range, with both ends allowed to appear.

=RANDBETWEEN(1,100)
// Possible results: 1 through 100
Check Answer
Challenge #1
Target: Sheet1!D2

In cell D2, generate a random whole number from 1 to 100.

Example 2 - Simulate a Dice Roll

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.

This makes the example easy to connect to a real random process. The function matches the scenario neatly, so the formula is both simple and intuitive.

=RANDBETWEEN(1,6)
// Possible results: 1, 2, 3, 4, 5, or 6
Check Answer
Challenge #2
Target: Sheet1!D3

In cell D3, simulate a dice roll with a random integer from 1 to 6.

Example 3 - Reference the Bounds from Cells

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.

This is practical for testing and dashboards because the range can change with the inputs. The random formula stays the same while the allowed values adjust automatically.

=RANDBETWEEN(B1,C1)
// B1 = 50, C1 = 200
// Result is an integer from 50 through 200
Check Answer
Challenge #3
Target: Sheet1!D4

In cell D4, generate a random whole number between the limits in B4 and C4.

Example 4 - Generate Integers in a Negative Range

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.

That helps show the function is not limited to positive counts. It can also handle ranges that cross zero, which is useful in many simulation-style worksheets.

=RANDBETWEEN(-10,10)
// Possible results: -10 through 10
Check Answer
Challenge #4
Target: Sheet1!D5

In cell D5, generate a random whole number from -10 to 10.

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.

  • Both endpoints are included in the result set.
  • The function is volatile and recalculates automatically.
  • Use RAND instead when the model needs continuous decimals rather than integers.

Conclusion Recap

RANDBETWEEN is the easier choice when you want random whole numbers instead of random decimals. In this lesson, the main point was that both the lower and upper limits are included, so the result can land on either end of the range.

The examples kept it practical with things like dice rolls, cell-based ranges, and negative-to-positive ranges. Just remember that the value changes on recalculation, so it is useful for random testing and simulation, but not for final fixed numbers unless you freeze the results.

  • Summary: RANDBETWEEN returns a random integer between two inclusive bounds.
  • Syntax: =RANDBETWEEN(bottom,top).
  • Key behavior: The function is volatile and returns #NUM! when bottom is greater than top.
  • Practical usage: Dice-roll logic, test data, random IDs, and discrete simulations.
Tactical Arena
Share RANDBETWEEN Function!

Tell your friends about this post

Discussion

ExcelClash is an interactive platform designed to level up your Excel skills through real-world exercises and challenges. Sharpen your logic, solve real spreadsheet problems, and learn faster.

© 2026 ExcelClash, Inc. All rights reserved.