Random Number (RAND)

Syntax: RAND()

The RAND function returns a random fractional number between 0 and 1. To make it a bit more useful, you can multiply it by 10 and use TRUNC to turn the results into integers from 0 to 10. Here's an example:

=TRUNC(RAND()*10)

Multiplying RAND by 100 in the preceding example returns numbers from 0 to 100.

images

Figure 6-6. Sample result of the RAND function

If you want random numbers from a different range, such as 1970 to 2010, use the following trick:

=TRUNC(RAND()*40)+1970

See also the section on the TRUNC function.

Get Beginning OpenOffice Calc: From Setting Up Simple Spreadsheets to Business Forecasting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.