VBA!! Multi slip lottery checker

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Hello,


  1. Draw results in C3:G22
  2. 10 play slip O3:S12 each with 5 numbers

VBA that check 10 play match 2, 3, 4 and 5 list 1st with result C3:G3 dated 12/02/2004 and write them in I3:L3 (result shows find 2 match only in 1 play slip)
Another example draw dated 19/03/2004 find 2 match in 2 play slips and so on…

Finally I need to check 10-play slip with each draw here is the example showing results in I3:L22


Book1
ABCDEFGHIJKLMNOPQRS
1YearFECHAn1n2n3n4n5EMMatchMatchMatchMatchEM 1Play Slipn1n2n3n4n5
2YearFECHAn1n2n3n4n5EM2 num3 num4 num5 numEM 1Nn1n2n3n4n5
3200413/02/200416293236411Play Slip 1431323441
4200420/02/20047133947501Play Slip 21227464849
5200427/02/20041418193137Play Slip 3929374547
6200405/03/200447333739Play Slip 4211151926
7200412/03/20041524284447Play Slip 517182225
8200419/03/200433363742452Play Slip 6810131439
9200426/03/200434102343Play Slip 71633404344
10200402/04/20044122427362Play Slip 81721243642
11200409/04/200414101923Play Slip 93562035
12200416/04/20041415283540Play Slip 102328303850
13200423/04/2004610214549
14200430/04/2004561623271
15200407/05/200415162136381
16200414/05/200413213239
17200421/05/200415293739491
18200428/05/200435641441
19200404/06/20049293445471
20200411/06/200427810471
21200418/06/2004171822251
22200425/06/20043213034351
Results Checker


Thanks In Advance
Using version 2000

Regards,
Moti
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Searching in google and even through excel forums I do not find any multi slip lottery checker?

Do Any body have come across please help

Regards,
Moti
 
Upvote 0
Code:
Public Sub LotteryChecker()

Dim lastRow As Long
Dim dateLoop As Long
Dim slipLoop As Long
Dim i As Long
Dim j As Long
Dim matchCount As Long
Dim numCount(5) As Long
Dim firstDraw As Range
Dim allSlips As Range
Dim allCounts As Range

Set firstDraw = Range("$C$3")
Set allSlips = Range("$O$3:$S$12")
Set allCounts = Range("$I$3:$L$22")

lastRow = Cells(Rows.Count, firstDraw.Column).End(xlUp).Row

For dateLoop = firstDraw.Row To lastRow
    Erase numCount
    
    For slipLoop = allSlips.Row To allSlips.Row + allSlips.Rows.Count - 1
        matchCount = 0
        For i = firstDraw.Column To firstDraw.Column + 4
            For j = allSlips.Column To allSlips.Column + 4
                matchCount = matchCount + IIf(Cells(dateLoop, i).Value = Cells(slipLoop, j).Value, 1, 0)
            Next j
        Next i
        numCount(matchCount) = numCount(matchCount) + 1
    Next slipLoop
    
    For i = 2 To 5
        Cells(dateLoop, allCounts.Column + i - 2) = IIf(numCount(i) = 0, "", numCount(i))
    Next i
Next dateLoop

End Sub

WBD
 
Upvote 0
Code:
Public Sub LotteryChecker()
WBD
Spot on wideboydixon, exactly that is it I was looking for. I think this is the first multiple Lottery checker on this forum

I appreciate a lot your help my query is solved

Thank you

Regards,
Moti :)
 
Last edited:
Upvote 0
Upvote 0
I tried to solve with formulas:

in I3 then drag till L22

Code:
=--(SUMPRODUCT(COUNTIF(C3:G3,$O$3:$S$3))=--LEFT(I$2))+--(SUMPRODUCT(COUNTIF(C3:G3,$O$4:$S$4))=--LEFT(I$2))+--(SUMPRODUCT(COUNTIF(C3:G3,$O$5:$S$5))=--LEFT(I$2))+--(SUMPRODUCT(COUNTIF(C3:G3,$O$6:$S$6))=--LEFT(I$2))+--(SUMPRODUCT(COUNTIF(C3:G3,$O$7:$S$7))=--LEFT(I$2))+--(SUMPRODUCT(COUNTIF(C3:G3,$O$8:$S$8))=--LEFT(I$2))+--(SUMPRODUCT(COUNTIF(C3:G3,$O$9:$S$9))=--LEFT(I$2))+--(SUMPRODUCT(COUNTIF(C3:G3,$O$10:$S$10))=--LEFT(I$2))+--(SUMPRODUCT(COUNTIF(C3:G3,$O$11:$S$11))=--LEFT(I$2))+--(SUMPRODUCT(COUNTIF(C3:G3,$O$12:$S$12))=--LEFT(I$2))

I don't like this kind of huge formulas, I prefer a vba solution, but I see on the forum they are used widely. Is there a way to make it smaller?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,222,569
Messages
6,166,837
Members
452,077
Latest member
hufflefry

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