RAND Function (OpenOffice Calc)
The RAND function in OpenOffice Calc returns a random decimal number between 0 and 1. 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 RAND function in OpenOffice Calc returns a random decimal number between 0 and 1. It recalculates every time the sheet recalculates, making it ideal for simulations, sampling, random selection, and procedural generation.
What the RAND Function Does
- Returns a random decimal number in the range 0 ≤ x < 1
- Recalculates on every sheet update
- Useful for simulations, sampling, shuffling, and procedural logic
- Works across sheets
- Pairs naturally with INT, ROUND, and RAND BETWEEN
RAND is ideal when you need uniform random values.
Syntax
RAND()
Arguments:
- None — RAND takes no parameters.
To freeze a value, copy → Paste Special → Values Only.
Basic Examples
Generate a random decimal between 0 and 1
=RAND()
Generate a random decimal between 0 and N
=RAND() * N
Generate a random decimal between A and B
=A + RAND() * (B - A)
Integer Randomization (Manual RAND.BETWEEN)
Random integer between 1 and 10
=INT(RAND() * 10) + 1
Random integer between A and B
=INT(RAND() * (B - A + 1)) + A
Random even number between 0 and 20
=INT(RAND() * 11) * 2
Random multiple of 5 between 0 and 100
=INT(RAND() * 21) * 5
Advanced Examples
Random boolean (TRUE/FALSE)
=RAND() < 0.5
Random sign (−1 or +1)
=IF(RAND() < 0.5; -1; 1)
Random selection from a list
=INDEX(List; INT(RAND() * ROWS(List)) + 1)
Shuffle rows (sort by RAND)
Add a helper column:
=RAND()
Then sort by that column.
Random date between two dates
=StartDate + INT(RAND() * (EndDate - StartDate + 1))
Random time of day
=RAND()
(Time is stored as a fraction of a day.)
Random normal distribution (Box–Muller)
=SQRT(-2 * LN(RAND())) * COS(2 * PI() * RAND())
Random yes/no with weighted probability
70% yes, 30% no:
=IF(RAND() < 0.7; "Yes"; "No")
RAND across sheets
=RAND()
(Each call is independent.)
Recalculation Behavior
RAND updates when:
- You edit any cell
- You press F9
- You open the file
- Dependent formulas recalc
To freeze values:
- Select the RAND cells
- Copy
- Paste Special → Values Only
Common Errors and Fixes
RAND returns Err:508 (Missing parenthesis)
Occurs when:
- You forget the parentheses:
=RANDinstead of=RAND() - You mix commas and semicolons
RAND returns unexpected results
Possible causes:
- Forgetting that RAND recalculates
- Using RAND inside volatile formulas
- Using RAND for integer ranges without INT
RAND ignores values you expected it to include
RAND ignores:
- All arguments (it takes none)
- Text
- Logical values
RAND includes values you expected it to ignore
RAND includes:
- Nothing — it generates its own value
Best Practices
- Use RAND for simulations and sampling
- Use INT(RAND()*N)+1 for integer ranges
- Freeze values when you need reproducibility
- Use RAND with INDEX for random selection
- Use RAND with SORT for shuffling
- Use RAND with LN and PI for random distributions