Microsoft KB Archive/49282

{| = Excel: Generating a Random Number Between Two Values =
 * width="100%"|

Last reviewed: November 2, 1994

Article ID: Q49282

SUMMARY
RAND generates a new random number between 0 and 1 (exclusive) every time the sheet is recalculated.

To generate a random decimal number between two given values, use RAND in the following formula:

=(endnum-beginnum)*RAND+beginnum To generate a random integer between two given integers, include the above formula in an INT statement, as follows =INT((endnum-beginnum+1)*RAND)+beginnum where beginnum is the smallest and endnum is the largest random numbers you want returned. Note that for generating numbers between 0 (zero) and a given number, the formulas simplify to the following: =endnum*RAND          For decimal numbers between zero and endnum =INT((endnum+1)*RAND) For integers between zero and endnum
 * }