ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   random number (https://www.excelbanter.com/excel-programming/378126-random-number.html)

Jean-Paul De Winter

random number
 
Hi
I need a random number... or it is 1 or it is 2
Now I use this "formula"
score = Int(Right(Val(Second(Now()) * 3.14), 1))
If score = 6 Then score = 2 Else score = 1
it is placed in a loop but doesn't really returns 1 and 2 randomly

Any idea?
Thanks

Gary''s Student

random number
 
=RANDBETWEEN(1,2)

will return 1 or 2 with even distribution
--
Gary's Student


"Jean-Paul De Winter" wrote:

Hi
I need a random number... or it is 1 or it is 2
Now I use this "formula"
score = Int(Right(Val(Second(Now()) * 3.14), 1))
If score = 6 Then score = 2 Else score = 1
it is placed in a loop but doesn't really returns 1 and 2 randomly

Any idea?
Thanks


Nigel

random number
 
This yields a positive integer of 1 or 2; as random as XL is using the built
in random function

score = Int((2) * Rnd + 1)


--
Cheers
Nigel



"Jean-Paul De Winter" wrote in message
...
Hi
I need a random number... or it is 1 or it is 2
Now I use this "formula"
score = Int(Right(Val(Second(Now()) * 3.14), 1))
If score = 6 Then score = 2 Else score = 1
it is placed in a loop but doesn't really returns 1 and 2 randomly

Any idea?
Thanks




Nigel

random number
 
If you are using Excel 2003 then make sure that this issue is addressed ...

http://support.microsoft.com/kb/834520/


--
Cheers
Nigel



"Gary''s Student" wrote in message
...
=RANDBETWEEN(1,2)

will return 1 or 2 with even distribution
--
Gary's Student


"Jean-Paul De Winter" wrote:

Hi
I need a random number... or it is 1 or it is 2
Now I use this "formula"
score = Int(Right(Val(Second(Now()) * 3.14), 1))
If score = 6 Then score = 2 Else score = 1
it is placed in a loop but doesn't really returns 1 and 2 randomly

Any idea?
Thanks




Bernard Liengme

random number
 
Or
=1+(RAND()0.5)

--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Jean-Paul De Winter" wrote in message
...
Hi
I need a random number... or it is 1 or it is 2
Now I use this "formula"
score = Int(Right(Val(Second(Now()) * 3.14), 1))
If score = 6 Then score = 2 Else score = 1
it is placed in a loop but doesn't really returns 1 and 2 randomly

Any idea?
Thanks





All times are GMT +1. The time now is 03:08 PM.

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