Check my entire betting sets with whole results

Kishan

Well-known Member
Joined
Mar 15, 2011
Messages
1,648
Office Version
  1. 2010
Platform
  1. Windows
Using Excel 2000

Hi,

This is challenging task;

I got results in the columns C:P (R1 Through R14)
I got betting sets in the columns R:AE (B1 Through B14)
I want to check my entire betting sets R:AE with whole results C:P
Check the matches only if the correct are grater than 9 to 14, because less than 10 winning price value are 0
And show matching results grater than 9 to 14 in columns AG:AK

The below example is showing some matching results...
Note: as this is an example so it has show with few data sets, Actually I have 4000+ rows with results, which I want to check with 19000+ rows betting sets


Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKAL
4
5R1R2R3R4R5R6R7R8R9R10R11R12R13R14B1B2B3B4B5B6B7B8B9B10B11B12B13B141011121314
6X11121212X11X11111111111111130120
7XX21XX1121X21111122111111X1220000
811111111122111111211X111X2X111000
9211X21X1122111111X1X11XX121110000
101X1X11211XXX1111X2111122112110000
11X2XX2X11211112X1X111X1X1121110000
12X112111211X1X1112X121X111X1110000
131XX21X111211X112X1211X11X11100000
141112XXX1XX1XXX112XX1121111X120000
151XX11111X112X1X112111221211101000
16X1X212XXX111XX12X1XX1111111X20000
1711X121X11121X12X2X22XX1X222200000
1811111X11122X11
19X11XX1111211XX
20111121XX12X1X2
211112211X1211X1
2221X11X11121112
231111121121XXX1
24X11211211X111X
251111X111111111
26X1111211XX11X1
2712XXXX12111X11
28111212XXXX1X1X
29111221X1X121X2
30111X111X11X112
31111X1111111111
321X11211XXX1X21
332211X1X21221X1
341X12111111X1X1
3521112X1XX11XX1
361XX2112X11X12X
37X111111112XXXX
38X211XX1112X111
39X12121XXXXX112
40111XX12X121XX1
41XXX11X1111XX11
42
Sheet1


Thank you in advance

Regards,
Kishan
 

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.
I'm a bit confused.

Do you want to compare C6:P6 with every row in the range R6:AR17? And when you compare them, you're checking to see if C6=R6, D6=S6, E6=T6, etc.? So Row 6 compared with row 6 gives a count of 8, and row 6 compared with row 7 gives a count of 6? Then in AG6:AK6 list the count of rows that match the given count?

If so, try this:

Code:
Sub MatchSets()
Dim r1 As Long, r2 As Long, i As Long, j As Long, Arr1 As Variant, Arr2 As Variant, Arr3() As Long, ctr As Long

    r1 = Cells(Rows.Count, "C").End(xlUp).Row
    r2 = Cells(Rows.Count, "R").End(xlUp).Row
    
    Arr1 = Range("C6:P" & r1).Value
    Arr2 = Range("R6:AE" & r2).Value
    ReDim Arr3(0 To UBound(Arr1), 1 To 5)
    For i = 1 To 5
        Arr3(0, i) = i + 9
    Next i
    
    For i = 1 To UBound(Arr1)
        For j = 1 To UBound(Arr2)
            ctr = 0
            For k = 1 To 14
                If Arr1(i, k) = Arr2(j, k) Then ctr = ctr + 1
            Next k
            If ctr > 9 Then Arr3(i, ctr - 9) = Arr3(i, ctr - 9) + 1
        Next j
    Next i
    
    Cells(5, "AG").Resize(UBound(Arr1), 5).Value = Arr3
    
End Sub

The results I got for the sample data do not match your values at all. Also, if your range is 4000 times 19,000, the number of loops would be something like 4000 X 19000 X 14 = 1.064 billion, so it might take a while. It's possible that a more clever algorithm could speed it up some, but this version is about as optimized as I can do.
 
Upvote 0
I'm a bit confused.

Do you want to compare C6:P6 with every row in the range R6:AR17? And when you compare them, you're checking to see if C6=R6, D6=S6, E6=T6, etc.? So Row 6 compared with row 6 gives a count of 8, and row 6 compared with row 7 gives a count of 6? Then in AG6:AK6 list the count of rows that match the given count?

If so, try this:

Code:
Sub MatchSets()
Dim r1 As Long, r2 As Long, i As Long, j As Long, Arr1 As Variant, Arr2 As Variant, Arr3() As Long, ctr As Long

    r1 = Cells(Rows.Count, "C").End(xlUp).Row
    r2 = Cells(Rows.Count, "R").End(xlUp).Row
    
    Arr1 = Range("C6:P" & r1).Value
    Arr2 = Range("R6:AE" & r2).Value
    ReDim Arr3(0 To UBound(Arr1), 1 To 5)
    For i = 1 To 5
        Arr3(0, i) = i + 9
    Next i
    
    For i = 1 To UBound(Arr1)
        For j = 1 To UBound(Arr2)
            ctr = 0
            For k = 1 To 14
                If Arr1(i, k) = Arr2(j, k) Then ctr = ctr + 1
            Next k
            If ctr > 9 Then Arr3(i, ctr - 9) = Arr3(i, ctr - 9) + 1
        Next j
    Next i
    
    Cells(5, "AG").Resize(UBound(Arr1), 5).Value = Arr3
    
End Sub

The results I got for the sample data do not match your values at all. Also, if your range is 4000 times 19,000, the number of loops would be something like 4000 X 19000 X 14 = 1.064 billion, so it might take a while. It's possible that a more clever algorithm could speed it up some, but this version is about as optimized as I can do.

Hi Eric, first of all big thanks for making a smart code, which is lifesaver, checking only the few lines manually require hours and hours, I like the macro very much! And also it is giving the same results as shown in my example post#1 only the way is different here is my view point please if you could alter I will be grateful to you.

I And when you compare them, you're checking to see if C6=R6, D6=S6, E6=T6, etc.?

Yes this is the idea, you got it perfectly right.

Comparing method, I want to compare each betting sets is in range R:AE with entire results is in range C:P, and put the final result in AG:AK

For example check 1st betting row R6:AE6 with whole results, in the example below comparing the betting row R6:AE6 with results data there are 3 row with 10 winners, 1 row with 12 winners, and 2 rows with 13 winners so the final results 3, 1 & 2 is showing in row AG6:AK6 for betting set R6:AE6 and this comparing method will be continue for every betting rows.


Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKAL
4142120
5R1R2R3R4R5R6R7R8R9R10R11R12R13R14B1B2B3B4B5B6B7B8B9B10B11B12B13B141011121314
6X11121212X11X11111111111111130120
7XX21XX1121X21111122111111X1220000
81111111112211112111211X111X2X111000
9211X21X1122111111X1X11XX121110000
101X1X11211XXX1111X2111122112110000
11X2XX2X11211112X1X111X1X1121110000
12X112111211X1X1112X121X111X1110000
131XX21X111211X112X1211X11X11100000
141112XXX1XX1XXX112XX1121111X120000
151XX11111X112X1X112111221211101000
16X1X212XXX111XX12X1XX1111111X20000
1711X121X11121X12X2X22XX1X222200000
1811111X11122X1110
19X11XX1111211XX
20111121XX12X1X2
211112211X1211X1
2221X11X11121112
231111121121XXX1
24X11211211X111X
251111X11111111113
26X1111211XX11X1
2712XXXX12111X11
28111212XXXX1X1X
29111221X1X121X2
30111X111X11X11210
31111X111111111113
321X11211XXX1X21
332211X1X21221X1
341X12111111X1X110
3521112X1XX11XX1
361XX2112X11X12X
37X111111112XXXX
38X211XX1112X111
39X12121XXXXX112
40111XX12X121XX1
41XXX11X1111XX11
42
Sheet1


I hope I have made a bit clearer

Regards,
Kishan
 
Upvote 0
If I understand correctly, then it's just a matter of changing the order that the arrays are compared:

Rich (BB code):
Sub MatchSets()
Dim r1 As Long, r2 As Long, i As Long, j As Long, Arr1 As Variant, Arr2 As Variant, Arr3() As Long, ctr As Long

    r1 = Cells(Rows.Count, "C").End(xlUp).Row
    r2 = Cells(Rows.Count, "R").End(xlUp).Row
    
    Arr1 = Range("C6:P" & r1).Value
    Arr2 = Range("R6:AE" & r2).Value
    ReDim Arr3(0 To UBound(Arr2), 1 To 5)
    For i = 1 To 5
        Arr3(0, i) = i + 9
    Next i
    
    For i = 1 To UBound(Arr2)
        For j = 1 To UBound(Arr1)
            ctr = 0
            For k = 1 To 14
                If Arr2(i, k) = Arr1(j, k) Then ctr = ctr + 1
            Next k
            If ctr > 9 Then Arr3(i, ctr - 9) = Arr3(i, ctr - 9) + 1
        Next j
    Next i
    
    Cells(5, "AG").Resize(UBound(Arr2), 5).Value = Arr3
    
End Sub
 
Last edited:
Upvote 0
If I understand correctly, then it's just a matter of changing the order that the arrays are compared:

Rich (BB code):
Sub MatchSets()
Dim r1 As Long, r2 As Long, i As Long, j As Long, Arr1 As Variant, Arr2 As Variant, Arr3() As Long, ctr As Long

    r1 = Cells(Rows.Count, "C").End(xlUp).Row
    r2 = Cells(Rows.Count, "R").End(xlUp).Row
    
    Arr1 = Range("C6:P" & r1).Value
    Arr2 = Range("R6:AE" & r2).Value
    ReDim Arr3(0 To UBound(Arr2), 1 To 5)
    For i = 1 To 5
        Arr3(0, i) = i + 9
    Next i
    
    For i = 1 To UBound(Arr2)
        For j = 1 To UBound(Arr1)
            ctr = 0
            For k = 1 To 14
                If Arr2(i, k) = Arr1(j, k) Then ctr = ctr + 1
            Next k
            If ctr > 9 Then Arr3(i, ctr - 9) = Arr3(i, ctr - 9) + 1
        Next j
    Next i
    
    Cells(5, "AG").Resize(UBound(Arr2), 5).Value = Arr3
    
End Sub
Hi Eric, I thought might you need to rewrite, but just changing the orders it is working as appeal.

I am very grateful to you for giving a great solution

Thank you for your kind help

Have a good time

Regards,
Kishan :)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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