Random Number Generation

Article translations Article translations
Article ID: 86523 - View products that this article applies to.
This article was previously published under Q86523
Expand all | Collapse all


In Microsoft Excel, the RAND function uses the following iterative method to calculate pseudo-random numbers:

The first random number:

   random_number=fractional part of (9821 * r + 0.211327),
   where r = .5

Successive random numbers:

   random_number=fractional part of (9821 * r + 0.211327),
   where r = the previous random number

This formula will provide up to 1 million different numbers.


Computers cannot generate truly random numbers. Instead, they return a series of numbers based on a mathematical relationship that simulates "randomness." The "randomness" exhibited by the numbers is a function of the mathematical formula used by the random number generator.

In Microsoft Excel for Windows, adding randomize=1 to the [Microsoft Excel] section of the appropriate .INI file for your version of Microsoft Excel will cause "r" to be determined from the system clock (which adds a further degree of randomness to the numbers generated).

   For this version         The name of your
   of Microsoft Excel       .INI file is this

   5.0                      EXCEL5.INI
   4.0                      EXCEL4.INI
   3.0                      EXCEL.INI

Note that there is no such setting with Microsoft Excel for OS/2 or Microsoft Excel for the Macintosh.

NOTE: Excel 5.0 defaults to the RANDOMIZE=1 setting. Previous versions of Microsoft Excel defaulted to RANDOMIZE=0.


Article ID: 86523 - Last Review: November 16, 2006 - Revision: 1.4
  • Microsoft Excel 97 Standard Edition
  • Microsoft Excel 95 Standard Edition
  • Microsoft Excel 5.0 Standard Edition
  • Microsoft Excel 98 for Macintosh
kbinfo KB86523
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com