How to Generate 5/59 lotto numbers in 1 cell

testing lotto

New Member
Joined
Aug 7, 2011
Messages
29
I am looking for a way to generate 5 random lottery numbers sorted in numerical order in one cell, not 5 cells. for example, 03-13-22-39-51 contained in cell A1. Not 03 in cell A1 and 13 in B1, 22 in C1, 39 in D1, 51 in E1. I think it should be possible to do this ?
 
Run-Time Error -214741788(800010108)
Method _Default of object Range Failed.

This popped up the last time I had to do an End Task.

I have 168 historical numbers does that matter ? and want to use mx=10^9 but it crashes every time unless I make mx=10^4 or less.
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Your algorithm reached the bogo-algorithm level and needs a quantum computer to run it!! :D

Just wait and don't touch anything until it finishes running.
It might take years.
 
Upvote 0
You do realize there's approximately
(1/10)^45 and less chance of getting one lotto-number to match...

If you want to really be positive, this is the best chance you can get.
(1/59)^5
 
Last edited:
Upvote 0
The number of draws before repeating a given draw (or getting any other particular draw) has an exponential distribution; the CDF is

=1-exp(-draws/combin(59,5))

That reaches 50% probability after about 3.5M draws. There's a 10% chance you won't hit in 11.5M draws.

I don't think the code tells you anything more than how good your random number generator is, which for the VBA Rnd function, is pretty bad; it has a repeating cycle of about 16M (2^24 - 1) numbers.
 
Upvote 0
I don't think the code tells you anything more than how good your random number generator is, which for the VBA Rnd function, is pretty bad; it has a repeating cycle of about 16M (2^24 - 1) numbers.
Red - Actually, I think the code tells you rather more than this (like if anyone wants to generate lots of Lotto numbers, or pseudo-Lotto numbers, fast using VBA with Excel). Although I did note in Post#20 that this whole exercise (if conducted along the lines of this thread) really seems to have little purpose.

Blue - Thanks for that info. I didn't know the specific number, but have had my doubts in the past about the reliability of the VBA Rnd when the going gets tough.


Adding, for completeness I suppose, I do test my own codes before posting them, and in this case tested up to mx (max number of iterations to check against each historical Lotto number) = 50 million. With 27 to check against, that code has, with me, never failed to go through to completion within a reasonable time.
 
Upvote 0
The posted odds for winning with 5 numbers are 1 in: 5,138,133 (not including the 6th power ball) those odds are 1 in 195,249,054. I am only using the first 5 numbers, not the 6th. So the counts in column C should be 5,138,133 or less i woud think or some ones math is off ?<TABLE class=JackpotoddsTable><TBODY><TR><TD>
</TD><TD>1 in: 195,249,054.00
</TD></TR></TBODY></TABLE>
 
Upvote 0
I apologize, mirabeau, my post was poorly stated.

I wasn't criticizing your code (I didn't read it), but the purpose to which the OP wants it applied, suggestive that it might indicate whether one draw is likelier to repeat than any other.
 
Upvote 0
How can you tell if the program is running and not stuck in an endless loop. When I press Esc or Ctrl Break the screen turns a transperent gray also says not responding at top makes me think it is stuck somewhere or crashed ?
 
Upvote 0
The posted odds for winning with 5 numbers are 1 in: 5,138,133
=COMBIN(59, 5) = 5,006,386

So the counts in column C should be 5,138,133 or less
That's not correct. There are two possibilities in tossing a fair coin. That doesn't mean that you may not have to toss a coin more than twice to get heads.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,956
Messages
6,175,609
Members
452,660
Latest member
Zatman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top