ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   excel rand() negative (https://www.excelbanter.com/excel-programming/373710-excel-rand-negative.html)

Rustin

excel rand() negative
 
When I run the equation =rand() sometimes I get a negative number, when I
should get a number between 0 and 1. Am I doing something wrong or is this a
glitch? I am running excel 2003.

Helmut Weber[_2_]

excel rand() negative
 
Hi Rustin,

here and now not in a million times.

Sub test099856()
Dim lCnt As Long
Randomize
For lCnt = 1 To 1000000
If Rnd() < 0 Then Stop
Next
' Further checking by looking ar the results
For lCnt = 1 To 1000
Cells(lCnt, 1).Value = Rnd()
Next
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Dave Peterson

excel rand() negative
 
This was a bug in an early version of xl2003:

http://support.microsoft.com/kb/834520
The RAND function returns negative numbers in Excel 2003

http://support.microsoft.com/kb/828795/
Description of the RAND function in Excel 2003

But one of the service packs fixed it:
http://support.microsoft.com/ph/2512?sid=202


Rustin wrote:

When I run the equation =rand() sometimes I get a negative number, when I
should get a number between 0 and 1. Am I doing something wrong or is this a
glitch? I am running excel 2003.


--

Dave Peterson


All times are GMT +1. The time now is 02:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com