Microsoft KB Archive/49282

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 17:56, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Excel: Generating a Random Number Between Two Values

Last reviewed: November 2, 1994
Article ID: Q49282


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:


To generate a random integer between two given integers, include the above formula in an INT() statement, as follows


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

KBCategory: kbother


Additional reference words: 1.04 1.06 1.50 2.20 3.00

Last reviewed: November 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.