RANDBETWEEN Function (OpenOffice Calc)
The RANDBETWEEN function in OpenOffice Calc returns a random integer between two specified numbers. Learn syntax, recalculation behavior, examples, and best practices.
Compatibility
▾| Excel | ✔ |
| Gnumeric | ✖ |
| Google_sheets | ✔ |
| Libreoffice | ✔ |
| Numbers | ✔ |
| Onlyoffice | ✔ |
| Openoffice | ✔ |
| Wps | ✔ |
| Zoho | ✔ |
What the RANDBETWEEN Function Does ▾
- Returns a random integer
- Range is inclusive (both endpoints included)
- Recalculates on every sheet update
- Works across sheets
- Pairs naturally with RAND, INT, and INDEX
RANDBETWEEN is ideal when you need uniform random integers.
Syntax ▾
RANDBETWEEN(bottom; top)
Arguments:
- bottom — The lowest integer allowed
- top — The highest integer allowed
Both bottom and top must be integers or integer‑convertible values.
Basic Examples ▾
Random integer between 1 and 10
=RANDBETWEEN(1; 10)
Random integer between 0 and 100
=RANDBETWEEN(0; 100)
Random integer using cell references
=RANDBETWEEN(A1; B1)
Random negative integer range
=RANDBETWEEN(-10; -1)
Advanced Examples ▾
Random even number between 2 and 20
=RANDBETWEEN(1; 10) * 2
Random multiple of 5 between 0 and 100
=RANDBETWEEN(0; 20) * 5
Random date between two dates
=RANDBETWEEN(StartDate; EndDate)
Random time (in seconds)
=RANDBETWEEN(0; 86400) / 86400
Random selection from a list
=INDEX(List; RANDBETWEEN(1; ROWS(List)))
Random boolean (TRUE/FALSE)
=RANDBETWEEN(0; 1) = 1
Random sign (−1 or +1)
=IF(RANDBETWEEN(0; 1)=0; -1; 1)
RANDBETWEEN across sheets
=RANDBETWEEN(Sheet1.A1; Sheet1.B1)
Weighted random selection (manual)
If A1:A5 contains weights:
=MATCH(RAND(); CUMULATIVE_WEIGHTS_RANGE)
(Requires helper column.)
Recalculation Behavior ▾
RANDBETWEEN updates when:
- Any cell is edited
- The sheet recalculates
- You press F9
- The file is opened
To freeze values:
- Select the RANDBETWEEN cells
- Copy
- Paste Special → Values Only
Common Errors and Fixes ▾
RANDBETWEEN returns Err:502 (Invalid argument)
Occurs when:
- bottom or top is text
- bottom or top is empty
- bottom > top
- A malformed reference is used
RANDBETWEEN returns unexpected results
Possible causes:
- Forgetting that it recalculates
- Using decimals instead of integers
- Using volatile formulas that trigger recalculation
RANDBETWEEN ignores values you expected it to include
RANDBETWEEN ignores:
- Text numbers (
"123") - Empty cells
- Logical values
- Errors
RANDBETWEEN includes values you expected it to ignore
RANDBETWEEN includes:
- Both endpoints (inclusive)
- Numeric results of formulas
Err:508 — Missing parenthesis
Usually caused by:
- Missing
) - Using commas instead of semicolons
Best Practices ▾
- Use RANDBETWEEN for integer ranges
- Use RAND for decimal ranges
- Freeze values when reproducibility matters
- Use RANDBETWEEN with INDEX for random selection
- Use RANDBETWEEN with ROW for random row sampling
- Use named ranges for cleaner formulas
RANDBETWEEN is the fastest way to generate clean, reproducible integer randomness — perfect for simulations, sampling, and procedural logic.