Check betting sets

motilulla

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


I have a question I want to check my betting sets with all the results one by one and if matches greater than 10, 11, 12, 13, 14 filter those rows and copy paste them in another sheet one below another.


Data sheet is holding Results in the Columns C:P, Betting sets in the Columns R:AE, I am using formula in cell AF6 = SUMPRODUCT(--($C$6:$P$6=R6:AE6)) copied down to AF55 once match result are calculated I just filter AF row grater than 9 and copy data in sheet "Match Result"
Check for the next row match results I change the formula AF6 = SUMPRODUCT(--($C$7:$P$7=R6:AE6)) copied down to AF55 and repeat the process filter AF row grater than 9 and copy data in sheet "Match Result"

Is there any way it could be auto mechanize to check all result with betting sets and filter the matches and put them in the sheet "Match Result"

Sheet Data

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
1
2
3
4NYearn1n2n3n4n5n6n7n8n9n10n11n12n13n14EM1n1n2n3n4n5n6n7n8n9n10n11n12n13n14Match
5NYearn1n2n3n4n5n6n7n8n9n10n11n12n13n14EM1n1n2n3n4n5n6n7n8n9n10n11n12n13n14Match
612001111111111221111111111111111112
722001X11121212X11X1X2XX111X2112124
832001XX21XX1121X211X2X22X1121X2X22
942001211X21X1122111111221211221X110
10520011X1X11211XXX112X1X211122211X8
1162001X2XX2X11211112X1XX21X11222217
1272001X112111211X1X11X11211121XX217
13X1121212X2X1118
14112111X1122X1X10
15121X1X2X1XXX215
162212111X211X116
1712XX2X212X111X4
18111112X22211119
19X11221X22X11XX4
20221211121111217
21XX1X1121112X127
22112111X1122X1X10
2312X1211X11X1118
24212X2XX212211X6
25X2X12121XX11X24
26XXX1X1X11111117
271111XX111212X19
281XX1X1111212X18
29XX2X111111X2117
30X111XXX11111X26
31XX12XX11X1X2124
3212X11XX12111X16
33111211X111X2X18
34112XX1121111X17
35XX1111212X21XX7
36111211X111X2X18
37XX2X111111X2117
381X1X211X1X2X118
3921X1X111X2X1119
40X22121212211216
4111122111111X128
4221X121X2122X118
43111X1X1111212X9
44X1112121XXXXX25
452X121X21111X116
461211X221X111126
471111XX1211212X8
48XX111X12121X118
49X111XX211XX1118
5011XX1X2111XX117
511111222XXX11X16
52121112X21121218
53111221211221X110
54XX12X1111X11217
55112X121X111X117
Data


Sheet Match Result

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
1
2
3
4NYearn1n2n3n4n5n6n7n8n9n10n11n12n13n14EM1n1n2n3n4n5n6n7n8n9n10n11n12n13n14Match
5NYearn1n2n3n4n5n6n7n8n9n10n11n12n13n14EM1n1n2n3n4n5n6n7n8n9n10n11n12n13n14Match
612001111111111221111111111111111112
7111221211221X110
8112111X1122X1X10
9112111X1122X1X10
10111221211221X110
11
1222001X11121212X11X1X11221X22X11XX10
13X2X12121XX11X210
14XX1111212X21XX10
15X221212122112110
16X1112121XXXXX210
171111222XXX11X110
18
1932001XX21XX1121X211XX2X111111X21110
20XX12XX11X1X21210
21XX2X111111X21110
22
2342001211X21X1122111XX2X111111X21110
24XX12XX11X1X21210
25XX2X111111X21110
26
27520011X1X11211XXX11XX2X111111X21110
28XX12XX11X1X21210
29XX2X111111X21110
30
3162001X2XX2X11211112XX2X111111X21110
32XX12XX11X1X21210
33XX2X111111X21110
34
3572001X112111211X1X1XX2X111111X21110
36XX12XX11X1X21210
37XX2X111111X21110
Match Result


Thank you all
Excel 2000
Regards,
Moti
 
Re: Check betting sets not sure is it possible.

Hello, Rick Rothstein, I have a one question I am trying to check my 50 betting sets with over 250 results, but macro is checking only the 50 results and turns off. I am sure would require some adjustment as the question has changed.

Please could you take a look?

Thank you

Regards
Moti
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Re: Check betting sets not sure is it possible.

Hello, Rick Rothstein,

I thought better to show changed data sheet here. In this situation the code stop at the line below and if I check debug it gives error 1004

Code:
 Intersect(Columns("R:AE"), Cells(StartRow, "AF").Resize(UBound(SetData)).SpecialCells(xlConstants).EntireRow).Copy .Cells(NextRow, "R")

Please could you take a look?

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
1
2
3
4NYearn1n2n3n4n5n6n7n8n9n10n11n12n13n14EM1n1n2n3n4n5n6n7n8n9n10n11n12n13n14Match
5NYearn1n2n3n4n5n6n7n8n9n10n11n12n13n14EM1n1n2n3n4n5n6n7n8n9n10n11n12n13n14Match
6120011111111112211111111111111111
722001X11121212X11X1X2XX111X211212
832001XX21XX1121X211X2X22X1121X2X2
942001211X21X1122111111221211221X1
10520011X1X11211XXX112X1X211122211X
1162001X2XX2X11211112X1XX21X1122221
1272001X112111211X1X11X11211121XX21
138200112XXXX12111X11X1121212X2X111
1492001111212XXXX1X1X112111X1122X1X
15102001111221X1X121X2121X1X2X1XXX21
16112001111X111X11X1122212111X211X11
17122001111X111111111112XX2X212X111X
181320011X11211XXX1X21111112X2221111
191420012211X1X21221X1X11221X22X11XX
201520011X12111111X1X122121112111121
2116200121112X1XX11XX1XX1X1121112X12
221720011XX2112X11X12X112111X1122X1X
23182001X111111112XXXX12X1211X11X111
24192001X211XX1112X111212X2XX212211X
25202001X12121XXXXX112X2X12121XX11X2
26212001111XX12X121XX1XXX1X1X1111111
27222001XXX11X1111XX111111XX111212X1
282320012X21X1X11X12211XX1X1111212X1
29242001XX12X121111121XX2X111111X211
30252001XX1X1111X1211XX111XXX11111X2
3126200111X11211111X11XX12XX11X1X212
322720011111X2211111X112X11XX12111X1
332820012X11111X1111X1111211X111X2X1
34292001121X2121111111112XX1121111X1
35302001X1X12121X2XX21XX1111212X21XX
36312001X1111X11111112111211X111X2X1
37322001X1X11X2X1X2211XX2X111111X211
38332001X111XX1111112X1X1X211X1X2X11
39342001X1122X11111XX221X1X111X2X111
4035200121X21XXX1XX12XX2212121221121
41362001XX21X11211212111122111111X12
423720011X2X1212XX112X21X121X2122X11
43382001X2X11111121XXX111X1X1111212X
4439200111X11X11XX1111X1112121XXXXX2
451200211X111X11111112X121X21111X11
462200221X111211XXX1X1211X221X11112
4732002X122X11X1111111111XX1211212X
48420022111221122XX12XX111X12121X11
4952002111211111X2111X111XX211XX111
50620021X21X1121X221X11XX1X2111XX11
51720021X1X11XX111X111111222XXX11X1
5282002XXX11111111111121112X2112121
5392002XX22121X11X12X111221211221X1
5410200211211111X11111XX12X1111X1121
55112002X111X1121121XX112X121X111X11
561220021112X1X11X1XX1
571320021X1112X1XXX21X
5814200211X1XXX111X12X
591520021X1X1X22X11112
6016200211X22111X11112
611720021XX1X11121111X
621820021XXXX121111121
631920022X1X111112X122
6420200211X122211X1XX2
652120021111X111111XX1
66222002111121X11X1111
672320022X2X121X1X1XX1
6824200221X111112X111X
692520021111X1X12111X2
70262002X1212XX112X112
712720021X2221XX22XX11
722820021X11XX22XX11XX
732920021X1221X11X1221
74302002X1X1X11X111XX1
75312002XXX1111X1X212X
763220022X1112XXX11121
77332002X1XX1111111X11
783420021XX12121112X2X
79352002X2X11X1111X11X
80362002111111XXX1112X
813720021212X112X2111X
823820021XX112XX1X11X1
833920021XX11211221X11
84402002111X1111X11111
85412002X12X1112X112XX
86422002111X1XX1X11111
8743200211111XX2111112
8844200211111111112XX1
8945200212211111111X11
9046200211X11111111121
91472002XXX111X112X111
92482002X211211111XX1X
934920021X221112XX111X
9450200221XX11XX1X1111
955120021X12211112111X
Data




Thank you

Regards
Moti
 
Upvote 0
Re: Check betting sets not sure is it possible.

Hello, Rick Rothstein,

I thought better to show changed data sheet here. In this situation the code stop at the line below and if I check debug it gives error 1004

Code:
 Intersect(Columns("R:AE"), Cells(StartRow, "AF").Resize(UBound(SetData)).SpecialCells(xlConstants).EntireRow).Copy .Cells(NextRow, "R")

Please could you take a look?


Thank you

Regards
Moti
Hello, Rick Rothstein, Sorry for the inconvenience

I do not know what went wrong with my workbook I create a fresh workbook and Re:copy past macro is in the post#6 and I am surprised it is working correct with all results no problem at all.

Thank you very much for your help

Regards
Moti :)
 
Last edited:
Upvote 0
Re: Check betting sets not sure is it possible.

I think Rick's code needs an adjustment to handle cases where no row in R6:AE55 (last data sample) has more than 9 matches.
For example, considering row 13 (8 -2001) there is no row in R6:AE55 with more than 9 matches.

I took a completely different approach and created a new version.

Code:
Sub aTestV1()
    Dim dic As Object, vData1 As Variant, vData2 As Variant, vBlank As Variant
    Dim i As Long, j As Long, k As Long, lIndex As Long, lCounter As Long
    Dim lNextFree As Long, bFound As Boolean, lFirstRow As Long
    
    Set dic = CreateObject("Scripting.Dictionary")
    dic.CompareMode = vbTextCompare
    
    Sheets("Match Result").Cells.ClearContents
    
    lFirstRow = 6 '<--adjust to suit
    With Sheets("Data")
        vData1 = .Range("A" & lFirstRow & ":P" & .Cells(.Rows.Count, "A").End(xlUp).Row)
        vData2 = .Range("R" & lFirstRow & ":AE" & .Cells(.Rows.Count, "R").End(xlUp).Row)
        vBlank = .Range("R1:AE1").Value
        .Range("A4:AE5").Copy Sheets("Match Result").Range("A4")
    End With
    
    lNextFree = lFirstRow
    For i = 1 To UBound(vData1)
        Sheets("Match Result").Range("A" & lNextFree).Resize(, 16) = Application.Index(vData1, i, 0)
        bFound = False
        For j = 1 To UBound(vData2, 1)
            lCounter = 0
            For k = 1 To UBound(vData2, 2)
                If vData1(i, k + 2) = vData2(j, k) Then lCounter = lCounter + 1
            Next k
            If lCounter > 9 Then
                bFound = True
                lIndex = lIndex + 1
                dic(lIndex) = Application.Index(vData2, j, 0)
            End If
        Next j
        lIndex = lIndex + 1
        dic(lIndex) = vBlank
        If Not bFound Then
            lIndex = lIndex + 1
            dic(lIndex) = vBlank
            Sheets("Match Result").Range("Q" & lNextFree) = "Not found"
        End If
        lNextFree = lFirstRow + dic.Count
    Next i
    
    With Sheets("Match Result")
        .Range("R" & lFirstRow).Resize(dic.Count, 14) = Application.Index(dic.items, 0, 0)
        .Cells.HorizontalAlignment = xlCenter
    End With
End Sub

M.
 
Last edited:
Upvote 0
Re: Check betting sets not sure is it possible.

I think Rick's code needs an adjustment to handle cases where no row in R6:AE55 (last data sample) has more than 9 matches.
:banghead: Hmm, I don't know why, but it didn't occur to me that one of the patterns would not have a match of 10 or more. Thanks for noting that. The fix for my code is simple... I just needed to put an error trap around the code line (see the red highlighted lines below) with the SpecialCells call in it...
Code:
[table="width: 500"]
[tr]
	[td]Sub CheckBettingSets()
  Dim Y As Long, S As Long, C As Long, NextRow As Long
  Dim YearData As Variant, SetData As Variant, Matches As Variant
  Const StartRow = 6
  YearData = Range(Cells(StartRow, "A"), Cells(Rows.Count, "P").End(xlUp))
  SetData = Range(Cells(StartRow, "R"), Cells(Rows.Count, "AE").End(xlUp))
  Cells(StartRow, "AF").Resize(UBound(SetData)).Clear
  With Sheets("Match Result")
    .Cells.Clear
    Range(Cells(StartRow - 2, "A"), Cells(StartRow - 1, "AF")).Copy .Cells(StartRow - 2, "A")
    For Y = 1 To UBound(YearData)
      ReDim Matches(1 To UBound(SetData), 1 To 1)
      For S = 1 To UBound(SetData)
        For C = 1 To UBound(SetData, 2)
          If YearData(Y, C + 2) = SetData(S, C) Then Matches(S, 1) = Matches(S, 1) + 1
        Next
        If Matches(S, 1) < 10 Then Matches(S, 1) = ""
      Next
      Cells(StartRow, "AF").Resize(UBound(Matches)) = Matches
      NextRow = .Cells(.Rows.Count, "R").End(xlUp).Offset(2).Row
      If NextRow = StartRow + 3 Then NextRow = NextRow - 1
      Cells(StartRow + Y - 1, "A").Resize(, UBound(YearData, 2)).Copy .Cells(NextRow, "A")
      .Cells(NextRow, "A").Resize(, UBound(YearData, 2)).HorizontalAlignment = xlCenter
      [B][COLOR="#FF0000"]On Error Resume Next[/COLOR][/B]
      Intersect(Columns("R:AE"), Cells(StartRow, "AF").Resize(UBound(SetData)).SpecialCells(xlConstants).EntireRow).Copy .Cells(NextRow, "R")
      [B][COLOR="#FF0000"]On Error GoTo 0[/COLOR][/B]
      Cells(StartRow, "AF").Resize(UBound(SetData)).Clear
    Next
  End With
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
Re: Check betting sets not sure is it possible.

I have also a version that list only rows that meet the condition (>9 matches)

Code:
Sub aTestV2()
    'List only rows that meet condition (>9 matches)
    Dim dic As Object, vData1 As Variant, vData2 As Variant, vBlank As Variant
    Dim i As Long, j As Long, k As Long, lIndex As Long, lCounter As Long
    Dim lNextFree As Long, bFound As Boolean, lFirstRow As Long
    
    Set dic = CreateObject("Scripting.Dictionary")
    dic.CompareMode = vbTextCompare
    
    Sheets("Match Result").Cells.ClearContents
    lFirstRow = 6 '<--adjust to suit
    With Sheets("Data")
        vData1 = .Range("A" & lFirstRow & ":P" & .Cells(.Rows.Count, "A").End(xlUp).Row)
        vData2 = .Range("R" & lFirstRow & ":AE" & .Cells(.Rows.Count, "R").End(xlUp).Row)
        vBlank = .Range("R1:AE1").Value
        .Range("A4:AE5").Copy Sheets("Match Result").Range("A4")
    End With
    
    lNextFree = lFirstRow
    
    For i = 1 To UBound(vData1)
        bFound = False
        For j = 1 To UBound(vData2, 1)
            lCounter = 0
            For k = 1 To UBound(vData2, 2)
                If vData1(i, k + 2) = vData2(j, k) Then lCounter = lCounter + 1
            Next k
            If lCounter > 9 Then
                bFound = True
                lIndex = lIndex + 1
                dic(lIndex) = Application.Index(vData2, j, 0)
            End If
        Next j
        
        If bFound Then
            Sheets("Match Result").Range("A" & lNextFree).Resize(, 16) = Application.Index(vData1, i, 0)
            lIndex = lIndex + 1
            dic(lIndex) = vBlank
        End If
        lNextFree = lFirstRow + dic.Count
    Next i
    
    With Sheets("Match Result")
        .Range("R" & lFirstRow).Resize(dic.Count, 14) = Application.Index(dic.items, 0, 0)
        .Cells.HorizontalAlignment = xlCenter
    End With
End Sub

M.
 
Upvote 0
Re: Check betting sets not sure is it possible.

:banghead: Hmm, I don't know why, but it didn't occur to me that one of the patterns would not have a match of 10 or more. Thanks for noting that. The fix for my code is simple... I just needed to put an error trap around the code line (see the red highlighted lines below) with the SpecialCells call in it...
Code:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Sub CheckBettingSets()
  Dim Y As Long, S As Long, C As Long, NextRow As Long
  Dim YearData As Variant, SetData As Variant, Matches As Variant
  Const StartRow = 6
  YearData = Range(Cells(StartRow, "A"), Cells(Rows.Count, "P").End(xlUp))
  SetData = Range(Cells(StartRow, "R"), Cells(Rows.Count, "AE").End(xlUp))
  Cells(StartRow, "AF").Resize(UBound(SetData)).Clear
  With Sheets("Match Result")
    .Cells.Clear
    Range(Cells(StartRow - 2, "A"), Cells(StartRow - 1, "AF")).Copy .Cells(StartRow - 2, "A")
    For Y = 1 To UBound(YearData)
      ReDim Matches(1 To UBound(SetData), 1 To 1)
      For S = 1 To UBound(SetData)
        For C = 1 To UBound(SetData, 2)
          If YearData(Y, C + 2) = SetData(S, C) Then Matches(S, 1) = Matches(S, 1) + 1
        Next
        If Matches(S, 1) < 10 Then Matches(S, 1) = ""
      Next
      Cells(StartRow, "AF").Resize(UBound(Matches)) = Matches
      NextRow = .Cells(.Rows.Count, "R").End(xlUp).Offset(2).Row
      If NextRow = StartRow + 3 Then NextRow = NextRow - 1
      Cells(StartRow + Y - 1, "A").Resize(, UBound(YearData, 2)).Copy .Cells(NextRow, "A")
      .Cells(NextRow, "A").Resize(, UBound(YearData, 2)).HorizontalAlignment = xlCenter
      [B][COLOR=#ff0000]On Error Resume Next[/COLOR][/B]
      Intersect(Columns("R:AE"), Cells(StartRow, "AF").Resize(UBound(SetData)).SpecialCells(xlConstants).EntireRow).Copy .Cells(NextRow, "R")
      [B][COLOR=#ff0000]On Error GoTo 0[/COLOR][/B]
      Cells(StartRow, "AF").Resize(UBound(SetData)).Clear
    Next
  End With
End Sub
[/TD]
[/TR]
</tbody>[/TABLE]
Rick Rothstein, it produce the error as I said in the post#12, but later it disappear when I checked with different results that I commented in the post#13

Thank you so much for making it correct, so not to produce any error next time in such situation.

Regards
Moti :)
 
Upvote 0
Re: Check betting sets not sure is it possible.

I have also a version that list only rows that meet the condition (>9 matches)

Code:
Sub aTestV2()
    'List only rows that meet condition (>9 matches)
    Dim dic As Object, vData1 As Variant, vData2 As Variant, vBlank As Variant
    Dim i As Long, j As Long, k As Long, lIndex As Long, lCounter As Long
    Dim lNextFree As Long, bFound As Boolean, lFirstRow As Long
    
    Set dic = CreateObject("Scripting.Dictionary")
    dic.CompareMode = vbTextCompare
    
    Sheets("Match Result").Cells.ClearContents
    lFirstRow = 6 '<--adjust to suit
    With Sheets("Data")
        vData1 = .Range("A" & lFirstRow & ":P" & .Cells(.Rows.Count, "A").End(xlUp).Row)
        vData2 = .Range("R" & lFirstRow & ":AE" & .Cells(.Rows.Count, "R").End(xlUp).Row)
        vBlank = .Range("R1:AE1").Value
        .Range("A4:AE5").Copy Sheets("Match Result").Range("A4")
    End With
    
    lNextFree = lFirstRow
    
    For i = 1 To UBound(vData1)
        bFound = False
        For j = 1 To UBound(vData2, 1)
            lCounter = 0
            For k = 1 To UBound(vData2, 2)
                If vData1(i, k + 2) = vData2(j, k) Then lCounter = lCounter + 1
            Next k
            If lCounter > 9 Then
                bFound = True
                lIndex = lIndex + 1
                dic(lIndex) = Application.Index(vData2, j, 0)
            End If
        Next j
        
        If bFound Then
            Sheets("Match Result").Range("A" & lNextFree).Resize(, 16) = Application.Index(vData1, i, 0)
            lIndex = lIndex + 1
            dic(lIndex) = vBlank
        End If
        lNextFree = lFirstRow + dic.Count
    Next i
    
    With Sheets("Match Result")
        .Range("R" & lFirstRow).Resize(dic.Count, 14) = Application.Index(dic.items, 0, 0)
        .Cells.HorizontalAlignment = xlCenter
    End With
End Sub

M.
Thank you Marcelo Branco, for the catching the error. And also thank you for making a new version, which is working perfect!! Now no need to put numbers in ROW A

Regards
Moti :)
 
Upvote 0
Re: Check betting sets not sure is it possible.

Rick Rothstein, it produce the error as I said in the post#12, but later it disappear when I checked with different results that I commented in the post#13

Thank you so much for making it correct, so not to produce any error next time in such situation.
Are you saying my new code is still producing an error when run the first time or are you saying it now runs correctly every time?
 
Upvote 0
Re: Check betting sets not sure is it possible.

Are you saying my new code is still producing an error when run the first time or are you saying it now runs correctly every time?

Hello,

Rick Rothstein, My English is not bad but is not good too. I am saying recent code posed in the post#15 is running flawless every time. :)

Have a nice weekend

Thank you for your help

Regards
Moti


 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,874
Members
452,949
Latest member
Dupuhini

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