Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Checking my lottery numbers

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Checking my lottery numbers

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


" 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Checking my lottery numbers

On Oct 14, 10:29*am, Joel 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



" 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
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
How do I set up a Lottery sydicate checking sheet in excel? Mye63 New Users to Excel 0 April 11th 06 01:16 PM
Checking Winning Numbers in the Lottery. Ann Excel Discussion (Misc queries) 4 May 18th 05 10:55 AM
how do i use excel to check my lottery numbers pat07734 Excel Programming 4 April 17th 05 07:02 PM
complex validation for lottery numbers [email protected] Excel Discussion (Misc queries) 2 February 9th 05 03:15 PM
combination of numbers in lottery knoertje[_6_] Excel Programming 32 October 12th 04 07:05 PM


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