Excel: Generating a Random Number Between Two ValuesLast reviewed: November 2, 1994Article ID: Q49282 |
SUMMARYRAND() 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()+beginnumTo generate a random integer between two given integers, include the above formula in an INT() statement, as follows
=INT((endnum-beginnum+1)*RAND())+beginnumwhere 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 |
KBCategory: kbother
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |