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.
Verification status: Consult the documentation, examples and any stated test scope below. How formula examples are checked
Availability and version history
- Introduced: Documented by Apache OpenOffice 4.1.16; original introduction not established.
- Availability: Supported in Apache OpenOffice 4.1.16, verified against its function registry. This identifies a supported release, not a final working version.
- Scope: Desktop Calc, using the English function name. Availability in other spreadsheet applications is separate.
- Checked: 2026-10-14 — function reference; versioned support. Documentation/source check; not a new native test. Existing example-specific test claims below retain their stated scope.
The RANDBETWEEN function in OpenOffice Calc returns a random integer between two specified numbers, inclusive. It is ideal for simulations, sampling, random selection, procedural generation, and any scenario where you need whole‑number randomness.
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
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