RANDBETWEEN Function in ONLYOFFICE Spreadsheet Editor: Syntax and Examples
Generate bounded random integers including endpoints, validate input cells, and interpret the NUM error.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in ONLYOFFICE Spreadsheet Editor. How formula examples are checked
Quick answer
=RANDBETWEEN(bottom, top) returns a random integer between the two supplied bounds, including both endpoints. For example =RANDBETWEEN(1,6) is expected to return one of 1, 2, 3, 4, 5 or 6; it is not possible to predict which number will be returned by a particular recalculation. If bottom exceeds top, the official ONLYOFFICE reference specifies a #NUM! error. Official article, accessed 2026-10-13.
Choose RANDBETWEEN for a practice-die example, fixed-size randomized integer IDs, test-data generation, or a classroom exercise. It is not documented as cryptographically secure or suitable for regulated/unbiased draws.
Exact vendor syntax, arguments and defaults
=RANDBETWEEN(bottom, top)
| Argument | Required? | Official meaning | Example |
|---|---|---|---|
bottom |
Yes | Smallest integer value | 1 or cell A2 |
top |
Yes | Largest integer value | 6 or cell B2 |
There are no optional arguments or defaults in the official syntax. BOTH integer endpoints are included; input order matters. The official function page documents the invalid-order error but does not specify coercion of decimal bounds, text numbers, dates or booleans in every release. Those cases require native testing instead of inferred behaviour from Excel.
Compatibility, locale and validation scope
The English ONLYOFFICE function catalogue and the official function article below were accessed on 2026-10-13. The catalogue covers the Spreadsheet Editor, while the Formula tab documentation explicitly illustrates both online and desktop interfaces. Neither article provides a minimum compatible Desktop Editors build or a release-by-release runtime matrix for this particular function.
- ONLYOFFICE Docs/web: included in the shared unversioned English Spreadsheet Editor help; behaviour described below is documentation-checked, not observed in a live web editor.
- ONLYOFFICE Desktop: the same function help is relevant to the desktop spreadsheet interface, but no installed version was executed; minimum supported build and edge-case parity remain unverified.
- Other editors: Excel compatibility is discussed only where official Microsoft documentation was checked; it is not a guarantee for LibreOffice, Google Sheets, imported workbooks, or all locales.
- Locale: all copy-ready examples use English names and commas, as illustrated in the English ONLYOFFICE documentation. Regional or localized installations may display other separators or translated function names. Inspect the function tooltip and regional settings in your own editor instead of blindly pasting examples (Advanced Settings).
- Validation performed: vendor documentation checking and independent mathematical calculations/range proofs for expected outputs. Native ONLYOFFICE Desktop execution: not run. Native ONLYOFFICE web execution: not run. No screenshots or observed formula outputs are claimed.
How to use and test in ONLYOFFICE
Open a blank worksheet, enter the provided inputs into the named cells, select an output cell, and type the formula with a leading =. Alternatively use Formula → Function, or the shortcut documented in the Insert Functions help. The Formula tab’s Calculation control can recalculate a sheet or workbook (Formula tab). If your installation rejects comma separators, use its actual localized formula syntax. Do not copy a column’s displayed sample results as though they were measured outputs.
Reproducible worksheet with input references
Enter the following numeric cells in a new workbook:
| Cell | Value | Meaning |
|---|---|---|
| A1 | Bottom (text label) |
Input column |
| B1 | Top (text label) |
Input column |
| A2 | 10 | Minimum integer |
| B2 | 20 | Maximum integer |
| C1 | Draw (text label) |
Formula column |
| C2 | =RANDBETWEEN(A2,B2) |
Random integer between 10 and 20 |
| D2 | =AND(C2>=A2,C2<=B2,MOD(C2,1)=0) |
Expected TRUE, checks the single draw in C2 |
The output C2 is unpredictable but satisfies the documented interval and integer type if the function behaves as specified. D2 is expected TRUE by independent logic. Use the same C2 reference for every check; multiple direct RANDBETWEEN calls can produce unrelated draws.
Reproducible formulas and expected results
| Formula | Expected result | Explanation |
|---|---|---|
=RANDBETWEEN(1,6) |
integer 1–6 inclusive | Six possible values |
=RANDBETWEEN(2,2) |
number 2 | Single allowed value |
=RANDBETWEEN(-3,3) |
integer -3–3 inclusive | Both negative and positive bounds |
=RANDBETWEEN(0,1) |
integer 0 or 1 | Two integer outcomes |
=RANDBETWEEN(100,999) |
integer 100–999 inclusive | Three-digit positive numbers |
=RANDBETWEEN(7,3) |
error #NUM! | Bottom > top is documented error |
=RANDBETWEEN(0,0) |
number 0 | Single-value interval |
=RANDBETWEEN(-4,-4) |
number -4 | Fixed negative value |
=RANDBETWEEN(1,6)+RANDBETWEEN(1,6) |
integer 2–12 inclusive | Two separate random draws |
=MOD(RANDBETWEEN(1,6),1) |
number 0 | All outcomes are integers |
=RANDBETWEEN(1,1)=1 |
TRUE | Both bounds equal one |
=AND(RANDBETWEEN(4,9)>=4,RANDBETWEEN(4,9)<=9) |
TRUE | Each call obeys its bound |
The examples above report either a bounded set, a deterministic special case, or the vendor-documented error. No fabricated random output is used. A compound formula containing two random function calls is not guaranteed to use the same draw twice.
Advanced examples
Draw from a configurable integer interval
Put 10 in A2 and 20 in B2, then =RANDBETWEEN(A2,B2) in C2. The expected result is an integer in [10,20], including endpoints. Put =AND(C2>=A2,C2<=B2,MOD(C2,1)=0) in D2 to validate C2. The integer check uses ONLYOFFICE MOD, which returns a remainder after division. If A2 is changed to 25 while B2 remains 20, the documented function error is #NUM!.
Model two six-sided dice
=RANDBETWEEN(1,6)+RANDBETWEEN(1,6) returns an integer from 2 through 12. Here each occurrence is a separate draw. That fact alone does not make all totals equally likely; middle totals can be reached in more combinations than extremes if draws are uniform, but ONLYOFFICE’s vendor page does not document distribution testing.
Use bounded random test IDs—but never permanent IDs
=RANDBETWEEN(100,999) selects a three-digit numeric test value. Duplicates are possible, and the value may be regenerated on recalculation. For permanent, unique or security-sensitive identifiers, use a deterministic ID generator designed for that purpose rather than this function. Consider checking collisions if testing a mock dataset.
Choose between RAND and RANDBETWEEN
Use =RAND() to obtain a real number in [0,1); use RANDBETWEEN to draw whole numbers in a closed interval. The function names are distinct and should not be treated as aliases. Both are present in the current function index. RAND documentation.
Troubleshooting and limits
| Symptom | Documented fact or likely cause | Safe next step |
|---|---|---|
#NUM! with =RANDBETWEEN(7,3) |
Officially documented bottom > top error | Ensure bottom ≤ top |
| Decimal/text inputs give unexpected results | Conversion of invalid types is not fully specified in current ONLYOFFICE article | Normalize to integer numeric inputs and test natively |
| A result differs from a screenshot | Output is intentionally random | Check inclusive bounds and integer type instead |
| A new draw unexpectedly changes | Recalculation/caching may be active | Inspect Formula → Calculation; preserve values if required |
| Formula displays as text or gives unknown-function error | Input format, missing =, localized formula name, or unsupported build |
Test =RANDBETWEEN(1,1) and check installation/version |
| Bounds read from text cells | Locale parsing or text typing can alter argument semantics | Convert or validate input cells first |
| Repeated generated IDs | Random draws do not enforce uniqueness | Add a duplicate audit or use a proper unique-ID mechanism |
Limits not verified: range sizes at numeric precision boundaries, how fractions are converted, PRNG statistical distribution, seeding, independence, cryptographic guarantees and precise recalc frequency. Neither a version-specific Desktop guarantee nor a mobile behaviour claim is made.
Compatibility notes
The official ONLYOFFICE function index and RANDBETWEEN page document the same formula shape commonly used in Microsoft Excel. Similar appearance is not proof of matching corner cases or identical random streams. Microsoft Excel recalculation features should not be described as ONLYOFFICE-specific shortcuts without native validation.
Official sources and research record
- ONLYOFFICE RANDBETWEEN — syntax, inclusive integer bounds and
#NUM!for reversed bounds, accessed 2026-10-13. - ONLYOFFICE RAND — separate decimal-random function, accessed 2026-10-13.
- ONLYOFFICE MOD — integer check, accessed 2026-10-13.
- ONLYOFFICE Insert Functions — official function category and formula entry, accessed 2026-10-13.
- ONLYOFFICE Formula tab — manual calculation and desktop/web interface, accessed 2026-10-13.
- ONLYOFFICE Advanced Settings — locale-related display settings, accessed 2026-10-13.
Verification limits: Native Desktop/web execution, localized parsing, precise recalculation triggers and random-generator quality were not tested. Historical release support remains unestablished.