Microsoft Office Tutorials and References
In Depth Information
Generating Random Numbers
Generating Random Numbers
Random numbers are often useful in spreadsheet applications. For example, you can fill a range
with random numbers in order to test formulas. Or, you can generate random numbers to
simulate various processes.
Excel provides several ways to generate random numbers.
Using the RAND function
The Excel RAND function generates a uniform random number between 0 and 1. In other words,
every number between 0 and 1 has an equal probability of being returned by the function.
If you need larger random numbers, just use a simple multiplication formula. The following
formula, for example, generates a uniform random number between 0 and 1000:
=RAND()*1000
To limit the random number to whole numbers, use the ROUND function:
=ROUND((RAND()*1000),0)
Using the RANDBETWEEN function
To generate uniform random integers between any two numbers, you can use the
RANDBETWEEN function. The following formula, for example, generates a random number
between 100 and 200:
=RANDBETWEEN(100,200)
In versions prior to Excel 2007, the RANDBETWEEN function is available only when the Analysis
Toolpak add-in is installed. For compatibility with previous versions (and to avoid using the
addin), use a formula like the following, where a represents the lower limit and b represents the
upper limit:
=RAND()*(b-a)+a

Search JabSto ::

Custom Search