Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Carmel
 
Posts: n/a
Default same number appears in a random number generator

My formula for a lottery number selector is =INT(49*RAND()) but the problem
is that sometimes it generates the same numbers two or more times. I know
its something to do with the IF function, but can work out how to stop it.
Please Help!
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Biff
 
Posts: n/a
Default same number appears in a random number generator

Hi!

Here's one way:

Enter your numbers in A1:A49.......1;2;3;4;5...49

Enter this formula in B1:

=RAND()

Enter this formula in C1:

=INDEX(A$1:A$49,RANK(B1,B$1:B$49))

Select both B1 and C1 and copy down to row 49.

Use C1:C6 as your numbers.

To generate a new draw just press F9. Theoretically, it's possible to get
repeats but highly unlikely.

Biff

"Carmel" wrote in message
...
My formula for a lottery number selector is =INT(49*RAND()) but the
problem
is that sometimes it generates the same numbers two or more times. I know
its something to do with the IF function, but can work out how to stop it.
Please Help!



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Biff
 
Posts: n/a
Default same number appears in a random number generator

Here's another way that guarantees no repeats:

Enter your numbers in A1:A49.

Enter this formula in B1:

=RAND()

Copy down to B49.

Select both column A and column B.

Do a sort on column B. Either ascending or descending, it doesn't matter.

Use A1:A6 as your numbers.

Repeat the sort for a new draw.

Biff

"Biff" wrote in message
...
Hi!

Here's one way:

Enter your numbers in A1:A49.......1;2;3;4;5...49

Enter this formula in B1:

=RAND()

Enter this formula in C1:

=INDEX(A$1:A$49,RANK(B1,B$1:B$49))

Select both B1 and C1 and copy down to row 49.

Use C1:C6 as your numbers.

To generate a new draw just press F9. Theoretically, it's possible to get
repeats but highly unlikely.

Biff

"Carmel" wrote in message
...
My formula for a lottery number selector is =INT(49*RAND()) but the
problem
is that sometimes it generates the same numbers two or more times. I
know
its something to do with the IF function, but can work out how to stop
it.
Please Help!





  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
daddylonglegs
 
Posts: n/a
Default same number appears in a random number generator


Carmel Wrote:
My formula for a lottery number selector is =INT(49*RAND()) but the
problem
is that sometimes it generates the same numbers two or more times. I
know
its something to do with the IF function, but can work out how to stop
it.
Please Help!


I believe Biff's given you a couple of good solutions.....just to also
point out that using

=INT(49*RAND())

would not only generate repeats but would also sometimes give you zero
....and never give you you 49.....!!


--
daddylonglegs
------------------------------------------------------------------------
daddylonglegs's Profile: http://www.excelforum.com/member.php...o&userid=30486
View this thread: http://www.excelforum.com/showthread...hreadid=545736

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
 
Posts: n/a
Default same number appears in a random number generator

Carmel wrote:
My formula for a lottery number selector is =INT(49*RAND())


FYI, if your intent is to generate numbers between 1 and 49 inclusive,
the formula should be 1+INT(49*RAND()).

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
Seed numbers for random number generation, uniform distribution darebo Excel Discussion (Misc queries) 3 April 21st 23 09:02 PM
random number with text T Harris Excel Worksheet Functions 10 December 30th 05 04:34 PM
random number [email protected] Excel Discussion (Misc queries) 2 November 22nd 05 11:12 PM
Can excel be used to create a random number generator? comotoman Excel Discussion (Misc queries) 2 September 16th 05 09:55 PM
How can I get Positive values only from the random number generat. Markw3700 Excel Discussion (Misc queries) 1 January 21st 05 12:37 AM


All times are GMT +1. The time now is 11:03 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"