RAND and Rnd in Excel

BRAD GILE ( (no email) )
Wed, 16 Jun 1999 16:06:35 -0500

As has been pointed out, RAND cannot be reseeded by the user. Excel
automatically reseeds using the Visual Basic Timer function, which uses the
system clock. If you go into the Visual Basic Editor, click on Help and ask
for info on the Randomize Statement, you get the following:

"Randomize Statement

Initializes the random-number generator.

Syntax

Randomize [number]

The optional number argument is a Variant or any valid numeric expression.

Remarks

Randomize uses number to initialize the Rnd function's random-number
generator, giving it a new seed value. If you omit number, the value
returned by the system timer is used as the new seed value.

If Randomize is not used, the Rnd function (with no arguments) uses the
same number as a seed the first time it is called, and thereafter uses the
last generated number as a seed value.

Note To repeat sequences of random numbers, call Rnd with a negative
argument immediately before using Randomize with a numeric argument. Using
Randomize with the same value for number does not repeat the previous
sequence."

As a parenthetical note, Rnd has been in Microsoft versions of BASIC since
the old BASICA and works surpisingly well.
There is a book I have on Visual Basic 6.0 at home that has a souped up
version of the VB6 random number generator.
I will try to find the code and pass it on.

Brad Gile

Visit the CAS Web Site at http://www.casact.org
===============================================
To subscribe or unsubscribe from CASNET:
Send an e-mail to caslists@lists.casact.org
Type in the body join casnet to subscribe
or leave casnet to unsubscribe.