Math & Trig

RANDBETWEEN Formula

RANDBETWEEN returns a random integer between two specified values (inclusive on both ends). Unlike RAND which gives decimals between 0 and 1, RANDBETWEEN gives whole numbers in any range you choose. It recalculates with every sheet change, so copy-paste as values to freeze results.

Syntax

RANDBETWEEN(bottom, top)
ParameterDescription
bottom Parameter of the RANDBETWEEN function.
top Parameter of the RANDBETWEEN function.
Try RANDBETWEEN in Viztab — free, no signup

Examples

Dice roll

Formula
=RANDBETWEEN(1, 6)
Returns a random integer from 1 to 6, simulating a standard die roll.

Random employee ID

Formula
=RANDBETWEEN(1000, 9999)
Returns a random 4-digit number like 4827. Useful for generating test IDs or codes.

Random date in 2025

Formula
=RANDBETWEEN(DATE(2025,1,1), DATE(2025,12,31))
Returns a random date in 2025. Format the cell as a date to see it properly (dates are stored as numbers internally).

Common Errors

#NUM!

Bottom must be less than or equal to top. =RANDBETWEEN(10, 5) returns #NUM! because the range is inverted.

#VALUE!

Non-numeric arguments return #VALUE!.

Tips

Inclusive on both ends

Both the bottom and top values can be returned. RANDBETWEEN(1,6) can return 1, 2, 3, 4, 5, or 6.

Generate test data

Fill a column with =RANDBETWEEN(18, 65) for random ages, or =RANDBETWEEN(30000, 120000) for random salaries in test datasets.

Random dates

Since dates are numbers internally, RANDBETWEEN works great for random dates. Wrap in DATE for bounds and format the output cell as a date.

Try RANDBETWEEN in Viztab

Import your data and use RANDBETWEEN with 370+ other formulas. No signup required.

Open Viztab

Related Formulas