PC Review


Reply
Thread Tools Rate Thread

Checking my lottery numbers

 
 
greerjohn2288@gmail.com
Guest
Posts: n/a
 
      14th Oct 2008
Hello All,

I have the 6 winning numbers in a history file in the format:
3,6,13,22,31,32
10,17,25,30,33,36

I also have the numbers we played in another location in the same
format. (Same file)
The formulas I tried became unmanagable and I could not finish.

Q: Does anyone have a bit of code/macro that will check our numbers
against the history and report if there are 4,5 matches? That is,
tell us if our numbers have won before.

I can modify my data format to suit your code if need be.

Thanks for any help.

Greer
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      14th Oct 2008
Try this code. The number of 4 matches will be put into the column next to
the numbers you play. The 5 matches in the next column and the 6 matches in
the 3rd column


Sub lottery()

Set Winners = Sheets("Sheet1").Range("A1:A200")

Set OurNumbers = Sheets("Sheet2").Range("A1:A100")

For Each OurNum In OurNumbers
Match4 = 0
Match5 = 0
Match6 = 0

OurArray = Split(OurNum, ",")
For Each WinNum In Winners

WinArray = Split(WinNum, ",")
Matches = 0
For i = LBound(OurArray) To UBound(OurArray)
For j = LBound(WinNum) To UBound(WinNum)
If OurArray(i) = WinNum(j) Then
Matches = Matches + 1
Exit For
End If
Next j
Next i
Select Case Matches

Case 4: Match4 = Match4 + 1
Case 5: Match5 = Match5 + 1
Case 6: Match6 = Match6 + 1
End Select

Next WinNum
OutNum.Offset(0, 1) = Match4
OutNum.Offset(0, 2) = Match5
OutNum.Offset(0, 3) = Match6

Next OurNum

End Sub


"(E-Mail Removed)" wrote:

> Hello All,
>
> I have the 6 winning numbers in a history file in the format:
> 3,6,13,22,31,32
> 10,17,25,30,33,36
>
> I also have the numbers we played in another location in the same
> format. (Same file)
> The formulas I tried became unmanagable and I could not finish.
>
> Q: Does anyone have a bit of code/macro that will check our numbers
> against the history and report if there are 4,5 matches? That is,
> tell us if our numbers have won before.
>
> I can modify my data format to suit your code if need be.
>
> Thanks for any help.
>
> Greer
>

 
Reply With Quote
 
greerjohn2288@gmail.com
Guest
Posts: n/a
 
      14th Oct 2008
On Oct 14, 10:29*am, Joel <J...@discussions.microsoft.com> wrote:
> Try this code. *The number of 4 matches will be put into the column next to
> the numbers you play. *The 5 matches in the next column and the 6 matches in
> the 3rd column
>
> Sub lottery()
>
> Set Winners = Sheets("Sheet1").Range("A1:A200")
>
> Set OurNumbers = Sheets("Sheet2").Range("A1:A100")
>
> For Each OurNum In OurNumbers
> * *Match4 = 0
> * *Match5 = 0
> * *Match6 = 0
>
> * *OurArray = Split(OurNum, ",")
> * *For Each WinNum In Winners
>
> * * * WinArray = Split(WinNum, ",")
> * * * Matches = 0
> * * * For i = LBound(OurArray) To UBound(OurArray)
> * * * * *For j = LBound(WinNum) To UBound(WinNum)
> * * * * * * If OurArray(i) = WinNum(j) Then
> * * * * * * * *Matches = Matches + 1
> * * * * * * * *Exit For
> * * * * * * End If
> * * * * *Next j
> * * * Next i
> * * * Select Case Matches
>
> * * * * *Case 4: Match4 = Match4 + 1
> * * * * *Case 5: Match5 = Match5 + 1
> * * * * *Case 6: Match6 = Match6 + 1
> * * * End Select
>
> * *Next WinNum
> * *OutNum.Offset(0, 1) = Match4
> * *OutNum.Offset(0, 2) = Match5
> * *OutNum.Offset(0, 3) = Match6
>
> Next OurNum
>
> End Sub
>
>
>
> "greerjohn2...@gmail.com" wrote:
> > Hello All,

>
> > I have the 6 winning numbers in a history file in the format:
> > 3,6,13,22,31,32
> > 10,17,25,30,33,36

>
> > I also have the numbers we played in another location in the same
> > format. (Same file)
> > The formulas I tried became unmanagable and I could not finish.

>
> > Q: *Does anyone have a bit of code/macro that will check our numbers
> > against the history and report if there are 4,5 matches? *That is,
> > tell us if our numbers have won before.

>
> > I can modify my data format to suit your code if need be.

>
> > Thanks for any help.

>
> > Greer- Hide quoted text -

>
> - Show quoted text -


Hello,

First up, thank you for your help.

I tried using the code but keep getting the error: Runtime error 13.
Type mismatch
On debugging it points to this line:

For j = LBound(WinNum) To UBound(WinNum)

I tried all I knew, including copying some of the winning numbers
directly into OurNumbers (Sheet2 A1:A100)

Any suggestions?

Thanks again,

greer
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
lottery numbers. Tgeary100@yahoo.co.u Windows Vista Mail 1 14th Oct 2009 01:44 PM
How do I set up a Lottery sydicate checking sheet in excel? =?Utf-8?B?TXllNjM=?= Microsoft Excel New Users 0 11th Apr 2006 01:16 PM
Bingo Lottery Winning Numbers =?Utf-8?B?Tm9taXMtTUNTRQ==?= Microsoft Excel Misc 1 13th Jan 2006 07:21 PM
Checking Winning Numbers in the Lottery. =?Utf-8?B?QW5u?= Microsoft Excel Misc 4 18th May 2005 10:55 AM
combination of numbers in lottery knoertje Microsoft Excel Programming 32 12th Oct 2004 07:05 PM


Features
 

Advertising
 

Newsgroups
 


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