Fixed bound for a stable example
| A | B | |
|---|---|---|
| 1 | Bottom | Top |
| 2 | 5 | 5 |
Formula: D2: =RANDBETWEEN(A2,B2)
Result: 5
Equal bounds make the only possible random result five.
In Google Sheets the bounds of RANDBETWEEN are both inclusive, and the value changes whenever the sheet recalculates.
RANDBETWEEN(bottom, top)Under File, Settings, Calculation you can choose to recalculate on change only, or also every minute or every hour.
For a fuller explanation of the arguments and common errors, see the RANDBETWEEN Excel guide.
| A | B | |
|---|---|---|
| 1 | Bottom | Top |
| 2 | 5 | 5 |
Formula: D2: =RANDBETWEEN(A2,B2)
Result: 5
Equal bounds make the only possible random result five.
| A | B | |
|---|---|---|
| 1 | Bottom | Top |
| 2 | 1 | 1 |
Formula: D2: =AND(RANDBETWEEN(A2,B2)>=A2,RANDBETWEEN(A2,B2)<=B2)
Result: TRUE
The degenerate interval verifies the inclusive boundary without relying on a changing value.
| A | B | |
|---|---|---|
| 1 | Bottom | Top |
| 2 | -3 | -3 |
Formula: D2: =RANDBETWEEN(A2,B2)
Result: -3
Negative integer bounds are accepted.
A tiny spreadsheet with example data. Edit the formula or any number and see the result.
Formula in D2: =RANDBETWEEN(1,100)
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Number | Step | Result | |
| 2 | 1234.567 | 50 | 59 | |
| 3 | 17 | 5 | ||
| 4 | -4.7 | 12 | ||
| 5 | 144 | 9 | ||
| 6 | 2.5 | 3 | ||
| 7 | 50 | 12 |
Google Sheets is used here only as a descriptive product name. FormulaCamp is not affiliated with Google.
Enter — commit · F2 — edit · F4 — $ in a reference · Ctrl+C/Ctrl+V — copy and paste · Ctrl+Z — undo
Esc or F6 — leave the sheet for the «Check» button · Shift+Tab in the first cell — back to the page