excel rand() negative

G

Guest

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.
 
H

Helmut Weber

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top