LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
TheRobsterUK
 
Posts: n/a
Default VBA "Rnd" Function: Truly Random?


Hi,

I am having some doubts over the VBA "Rnd" function about if it really
generates a random number (between 0 and 1). In the Help file, it
states that:

Returns a Single containing a random number.

Syntax

Rnd[(number)]

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

Return Values

If number is Rnd generates
Less than zero The same number every time, using number as the seed.
Greater than zero The next random number in the sequence.
Equal to zero The most recently generated number.
Not supplied The next random number in the sequence.

Remarks

The Rnd function returns a value less than 1 but greater than or equal
to zero.

The value of number determines how Rnd generates a random number:

For any given initial seed, the same number sequence is generated
because each successive call to the Rnd function uses the previous
number as a seed for the next number in the sequence.

Before calling Rnd, use the Randomize statement without an argument to
initialize the random-number generator with a seed based on the system
timer.


Does this mean that after the first random number is generated, this is
used as the seed for the next one and that the number sequence from then
on is pre-determined?

What I actually want is the VBA equivalent of the worksheet RAND()
function, but I need truly random numbers, not ones that are
pre-determined by what came before!

So if I have the following code:


Code:
--------------------
Let i = 1 to 1000
Range("A1") = Rnd
next i
--------------------


Does that generate 1,000 truly random numbers or will they be in a
pre-determined sequence?!!?

Thanks
-Rob


--
TheRobsterUK


------------------------------------------------------------------------
TheRobsterUK's Profile: http://www.excelforum.com/member.php...fo&userid=9924
View this thread: http://www.excelforum.com/showthread...hreadid=470300

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating function (vba) with range arguments Fredouille Excel Worksheet Functions 2 September 12th 05 11:01 AM
Automatically up date time in a cell Mark Excel Discussion (Misc queries) 5 May 12th 05 12:26 AM
Custom Function Spencer Hutton Excel Worksheet Functions 2 April 29th 05 08:21 PM
HOW CAN I GET OFFICE 2003 EXCEL BASIC TO NEST FUNCTIONS LIKE EXCE. Robert AS Excel Worksheet Functions 4 December 2nd 04 10:49 AM
Find a Function to use accross different worksheets R. Hale Excel Worksheet Functions 3 November 25th 04 07:07 AM


All times are GMT +1. The time now is 01:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"