Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default 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"
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
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
RAND() generates negative values??? expect_ed Excel Discussion (Misc queries) 2 October 22nd 09 06:25 PM
how can i set up rand or rand between to give only -1 or 1? Uesiet Excel Worksheet Functions 8 October 27th 08 02:28 PM
I get some negative numbers when I use the RAND() function--Why? CaliDave Excel Worksheet Functions 4 June 6th 06 01:20 AM
Excel 2003-RND() vs Rand() Leigh[_2_] Excel Programming 4 May 2nd 04 11:15 AM
Speed--Excel 2003 RAND vs. VBA Rnd... TIMERESRCH Excel Programming 2 February 5th 04 02:49 PM


All times are GMT +1. The time now is 04:14 PM.

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

About Us

"It's about Microsoft Excel"