Documentation/Calc Functions/RANDBETWEEN

From The Document Foundation Wiki
Jump to navigation Jump to search
Other languages:
English • ‎dansk



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:

RAND

ODF standard:

Section 6.16.51, part2

Equivalent Excel functions:

RANDBETWEEN