Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default 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



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
Addding a Random number to a fixed number..... Dermot Excel Discussion (Misc queries) 6 August 20th 06 12:17 PM
How can I match a random number with closest number from sequence? Matt Excel Worksheet Functions 4 August 3rd 06 01:22 AM
same number appears in a random number generator Carmel Excel Worksheet Functions 4 May 28th 06 12:22 AM
Generating (in a random order)each number once from a given number Neil Goldwasser Excel Worksheet Functions 2 December 2nd 05 11:27 PM
How do I find random number in list of random alpha? (Position is. jlahealth-partners Excel Discussion (Misc queries) 0 February 8th 05 05:31 PM


All times are GMT +1. The time now is 03:51 AM.

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"