RAND function

RAND() function

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

Return a random number between 0 and 1

=RAND()


RAND is useful for generating random numbers that recalculate every time a sheet is opened or changed or F9 is pressed.

RAND uses the Mersenne Twister algorithm (MT19937) to generate random numbers.


RAND and numbers.

In the examples below, the RAND function is used to generate volatile and non-volatile random numbers, in single cells and arrays.

Use the RAND function to generate random numbers.

Use the RAND function to generate random numbers.


Syntax

=RAND()

The RAND function has no arguments.


Try it now!

  • Enter your formulas into the grey cells.

Scope

RAND has no arguments to define.

  • Volatile number between 0 and 1:
=RAND() || result is a random number greater than or equal to 0 and less than 1.
  • Volatile number between 0 and 100:
=RAND()*100 || result is a random number greater than or equal to 0 and less than 100.
  • Volatile number between 10 and 20:
=RAND()*(20-10)+10 || result is a random number greater than or equal to 10 and less than 20.
  • Volatile whole number between 0 and 100:
=INT(RAND()*100) || result is a random integer greater than or equal to 0 and less than 100.
  • Non-volatile number between 0 and 1:
=RAND() then press F9 || result is a random number greater than or equal to 0 and less than 1 that does not change when the workbook is opened or changed.

Caveats

  • RAND is a volatile function that will change every time a workbook is opened or changed or the F9 key is pressed.
  • To create a single non-volatile random number, enter the RAND() function into the formula bar then press F9 to convert the formula into its result. Alternatively, copy and paste special values the result into the desired cell.
  • To create an array of random numbers, select the desired range, then enter =RAND() followed by CTRL + ENTER. This generates the formula {=RAND()}.
  • To create a random number between 2 values, use =RAND()*(value2-value1)+value1 (e.g. =RAND()*(20-10)+10).
  • The RANDBETWEEN and RANDARRAY (Excel 365) functions can also be used to generate random values between 2 values.

Related Functions

  • RANDARRAY: (Excel 365) return an array of random decimal or integer numbers between specified values.
  • RANDBETWEEN: to generate random integers between 2 values.

Functions Category

 


Register (for free!) or Login to access bonus materials

About xlsnippets

Learn how to master functions, charts, pivot tables and more using Excel for Microsoft Office 365. Simple instructions and embedded spreadsheets help you practise the basics.

Latest Updates

26 March 2022
26 March 2022
26 March 2022
25 March 2022
22 March 2022

Coming soon

xlsnippets.com is currently in beta version. More functions and bonus content for registered users will be added weekly. Detailed training courses with additional downloadable resources are also on the horizon!