How to generate random numbers
✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)Get random decimals, whole numbers in a range, or a whole grid of random values.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel (desktop) | =RANDBETWEEN(1,100) | Whole numbers, both bounds inclusive. RAND() for 0-1 decimals; RANDARRAY(5,3) for a grid (365). |
| Google Sheets | =RANDBETWEEN(1,100) | Identical, including RAND and RANDARRAY. |
| LibreOffice Calc | =RANDBETWEEN(1,100) | Identical; RANDARRAY works in 25.8+ per our tests. |
How it works
RANDBETWEEN gives whole numbers with both ends included; RAND gives decimals in [0,1) — scale with =RAND()*(max-min)+min. All of these are volatile: they re-roll on every edit or recalculation. To freeze a set of random values, copy the cells and Paste Special → Values only. (Our verification asserts the deterministic part — the bounds — since the values themselves change every run.)
Verified, not just documented
We ran =AND(RANDBETWEEN(1,100)>=1,RANDBETWEEN(1,100)<=100) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned True — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned True for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.
Functions used
RANDBETWEEN — see full Excel, Google Sheets & LibreOffice compatibility for each.