Going Stellar

Home/Google Sheets reference

Google Sheets function · Math

RAND in Google Sheets: syntax and examples

RAND returns a random decimal that is at least 0 and below 1. Scale it with multiplication, or wrap it in INT for whole numbers such as a die roll.

Syntax

RAND()

Examples

=AND(RAND()>=0,RAND()<1)

Result: TRUE

The output always falls in the range from 0 up to, but not including, 1. A fixed TRUE shows it, since the number itself changes.

Run in a Google Sheet (English US locale) on . The result changes over time; this is the value on the run date.

=ISNUMBER(RAND())

Result: TRUE

RAND returns a plain number, so it can be used in any arithmetic.

Run in a Google Sheet (English US locale) on . The result changes over time; this is the value on the run date.

=AND(RAND()*10>=0,RAND()*10<10)

Result: TRUE

Multiply to change the scale: RAND()*10 stays below 10.

Run in a Google Sheet (English US locale) on . The result changes over time; this is the value on the run date.

=AND(INT(RAND()*6)+1>=1,INT(RAND()*6)+1<=6)

Result: TRUE

A die roll: INT(RAND()*6)+1 gives a whole number from 1 to 6, never 7.

Run in a Google Sheet (English US locale) on . The result changes over time; this is the value on the run date.

=RAND()=RAND()

Result: FALSE

Two calls in one formula are two different draws, so they differ.

Run in a Google Sheet (English US locale) on . The result changes over time; this is the value on the run date.

Common errors

  • RAND takes no arguments. RAND(1) returns #N/A, and RAND without parentheses returns #NAME?.
  • Each call is a new draw: RAND()=RAND() is FALSE. To use one draw twice, keep it with LET or in a helper cell.
  • The result stays below 1. That is why INT(RAND()*6)+1 covers 1 to 6 and never reaches 7.
  • Whole numbers need INT around the product, or RANDBETWEEN(1,6) directly.

Compared with Excel

Same behavior and syntax as Excel RAND. Excel 365 adds RANDARRAY, which Sheets has as well.

Sources

  1. RAND (Docs Editors Help)

Markdown version · All functions