Hi
How can I randomly select six different numbers at any one time i.e lottery
numbers. I have tried using the formula
=INT(RAND()*49)+1, which works OK but I get repeated numbers, can anyone
help?
Keith
Hi
How can I randomly select six different numbers at any one time i.e lottery
numbers. I have tried using the formula
=INT(RAND()*49)+1, which works OK but I get repeated numbers, can anyone
help?
Keith
Keith,
Here is what I use for the California lottery to
pick 5 non duplicate numbers from 47 possible...
'-------------------------------------------
Dim i As Long
Dim j As Long
Dim ArrTwo(1 To 47) As Long
Dim ArrOne(1 To 5, 1 To 1) As Long
Do While j < 6
Randomize (Right(Timer, 2) * j)
'Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
i = Int(Rnd * 47 + 1)
If ArrTwo(i) <> 99 Then
ArrOne(j, 1) = i
ArrTwo(i) = 99
j = j + 1
End If
Loop
'-------------------------------------------
Regards,
Jim Cone
San Francisco, USA
"Keith Robinson" <Keith.Robinson28@ntlworld.com> wrote in
message news:IUt7e.13199$C2.4427@newsfe3-win.ntli.net...
> Hi
> How can I randomly select six different numbers at any one time i.e lottery
> numbers. I have tried using the formula
> =INT(RAND()*49)+1, which works OK but I get repeated numbers, can anyone
> help?
> Keith
>
>
>
Hi
The usual way to do this is to fill down 49 cells with the numbers 1 - 49
and then in the next column fill down
=RAND()
and then sort on the second column. You can then select the top 6 numbers.
Each time you sort on the column, the RAND will refresh and give you a
different list.
--
Andy.
"Keith Robinson" <Keith.Robinson28@ntlworld.com> wrote in message
news:IUt7e.13199$C2.4427@newsfe3-win.ntli.net...
> Hi
> How can I randomly select six different numbers at any one time i.e
> lottery
> numbers. I have tried using the formula
> =INT(RAND()*49)+1, which works OK but I get repeated numbers, can anyone
> help?
> Keith
>
>
>
Since you say this is for a lottery, I guess you'll be using it quite often.
This procedure will allow you to display a new set of numbers each time you
hit the <F9> key.
First, you have to enter the RAND() function in a column, and then refer to
that column with a formula.
Say you use Column Z.
Enter
=RAND()
in Z1, and copy down to Z49.
Then, place this formula anywhere, and copy it down as many rows as you wish
to display your random numbers:
=INDEX(ROW(A1:A49),RANK(Z1,Z1:Z49),Z1:Z49)
Now, every time you hit the <F9> (calculate) key, you'll get a new random
display.
--
HTH,
RD
==============================================
Please keep all correspondence within the Group, so all may benefit!
==============================================
"Keith Robinson" <Keith.Robinson28@ntlworld.com> wrote in message
news:IUt7e.13199$C2.4427@newsfe3-win.ntli.net...
Hi
How can I randomly select six different numbers at any one time i.e lottery
numbers. I have tried using the formula
=INT(RAND()*49)+1, which works OK but I get repeated numbers, can anyone
help?
Keith
It will really work better if all the numbers are included when you copy
down the formula.
Forgot to anchor the references with absolutes.
Use this:
=INDEX(ROW($A$1:$A$49),RANK(Z1,$Z$1:$Z$49),$Z$1:$Z$49)
--
Regards,
RD
--------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit !
--------------------------------------------------------------------
"RagDyeR" <ragdyer@cutoutmsn.com> wrote in message
news:OfiLlHQQFHA.1268@TK2MSFTNGP14.phx.gbl...
Since you say this is for a lottery, I guess you'll be using it quite often.
This procedure will allow you to display a new set of numbers each time you
hit the <F9> key.
First, you have to enter the RAND() function in a column, and then refer to
that column with a formula.
Say you use Column Z.
Enter
=RAND()
in Z1, and copy down to Z49.
Then, place this formula anywhere, and copy it down as many rows as you wish
to display your random numbers:
=INDEX(ROW(A1:A49),RANK(Z1,Z1:Z49),Z1:Z49)
Now, every time you hit the <F9> (calculate) key, you'll get a new random
display.
--
HTH,
RD
==============================================
Please keep all correspondence within the Group, so all may benefit!
==============================================
"Keith Robinson" <Keith.Robinson28@ntlworld.com> wrote in message
news:IUt7e.13199$C2.4427@newsfe3-win.ntli.net...
Hi
How can I randomly select six different numbers at any one time i.e lottery
numbers. I have tried using the formula
=INT(RAND()*49)+1, which works OK but I get repeated numbers, can anyone
help?
Keith
Take a look here:
http://www.mcgimpsey.com/excel/randint.html
Usage:
Select 6 cells and array-enter:
=RandInt(1,49)
In article <IUt7e.13199$C2.4427@newsfe3-win.ntli.net>,
"Keith Robinson" <Keith.Robinson28@ntlworld.com> wrote:
> How can I randomly select six different numbers at any one time i.e lottery
> numbers. I have tried using the formula
> =INT(RAND()*49)+1, which works OK but I get repeated numbers, can anyone
> help?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks