# Documentation/Calc Functions/RANDBETWEEN

TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate

## Function name:

RANDBETWEEN

## Category:

Mathematical

## Summary:

Returns an integer random number in a specified range.

## Syntax:

RANDBETWEEN(**Bottom**; **Top**)

## Returns:

Returns an integer random number between integers **Bottom** and **Top** (both inclusive). This function produces a new random number each time Calc recalculates. To force Calc to recalculate manually press F9.

## Arguments:

**Bottom** is an integer value or a reference to the cell containing that value which is the lower bound.

**Top** is an integer value or a reference to the cell containing that value which is the upper bound.

- If
**Bottom**is greater than**Top**, the function returns an error value. - If both
**Bottom**and**Top**are equal then the function returns that same value. - If arguments are not integer, then they are rounded to nearest integer either above or below. For eg. 5.4 is rounded to 5, 5.6 to 6 and 5.5 to 6.

## Additional details:

To generate random numbers which never recalculate:

- copy cells containing this function, and use
**Edit > Paste Special**(with**Paste All**and**Formulas**not marked and**Numbers**marked). - Use the Fill Cell command with random numbers (
**Sheet - Fill Cells - Fill Random Numbers**). It offers options to set a Minimum and Maximum limit in which the random number is generated.

Use the RANDBETWEEN.NV() function for non-volatile random numbers.

## Examples:

Formula | Description | Returns |
---|---|---|

=RANDBETWEEN(20;30) | a random integer between 20 and 30 | 23 |

=RANDBETWEEN(20.4;30.8) | a random integer between 20 and 31, rounding to closest integers | 27 |

## Related LibreOffice functions:

## ODF standard:

## Equivalent Excel functions:

RANDBETWEEN