Count and list paired combination from multiple list

HorseRacing

New Member
Joined
Jun 2, 2021
Messages
9
Office Version
  1. 2019
Platform
  1. Windows
Hi
I have data as shown in table below.


RaceTipster 1Tipster 2Tipster 3Tipster 4.......Tipster 12
1HorseyTableCarPhone
1TableHorseyHorseyHorsey
1ChairmancarPhoneTable
2
2..up to race 11

I want to list and count paired combination in multiple list (various Tipsters) for the first 2 horses they choose. Eg. of the 12 tipsters, how many chose Horsey and Table as their 1st 2 choice. In the given data answer should return 2.

HorseyTableCarPhone
Horsey-2
Table
Car1
Phone1

Please help.

If possible.....i would like to be extend to have paired combination that goes up to the 1st 3 combi. Meaning Horsey and Table appears as tips by Tipster 1, tipster 2 and Tipster 4...means this occurs 3 times. Even though it is not the 1st two choices by Tipster 4.

Thanks
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Welcome to the MrExcel forum!

This is probably better suited to a VBA solution, nevertheless, here's a formula version:

Book1
ABCDEFGHIJKLMNOPQR
1HorsesPairingsTimes chosenTipster 1Tipster 2Tipster 3Tipster 4Tipster 5Tipster 6Tipster 7Tipster 8Tipster 9Tipster 10Tipster 11Tipster 12
2SlowpokeSlowpokeHorsey1HorseyTableCarPhoneDarkHorseHorseyPhoneTableHorseyBigWinnerBigWinnerBigWinner
3HorseySlowpokeBigWinner2TableHorseyHorseyHorseyTableChairmanTablePhoneSlowpokeSlowpokecarHorsey
4BigWinnerSlowpokeChairman0ChairmancarPhoneTableSlowpokePhoneChairmanChairmanTablecarSlowpokePhone
5ChairmanSlowpokeTable2
6TableSlowpokeCar2
7CarSlowpokePhone0
8PhoneSlowpokeDarkHorse1
9DarkHorseHorseyBigWinner1
10HorseyChairman2
11HorseyTable4
12HorseyCar2
13HorseyPhone4
14HorseyDarkHorse0
15BigWinnerChairman0
16BigWinnerTable0
17BigWinnerCar2
18BigWinnerPhone1
19BigWinnerDarkHorse0
20ChairmanTable3
21ChairmanCar0
22ChairmanPhone3
23ChairmanDarkHorse0
24TableCar1
25TablePhone3
26TableDarkHorse1
27CarPhone1
28CarDarkHorse0
29PhoneDarkHorse0
30   
Sheet11
Cell Formulas
RangeFormula
C2:C30C2=IF(ROWS($C$2:$C2)>COMBIN(COUNTA($A$2:$A$16),2),"",INDEX(A$2:A$16,LOOKUP(ROWS(C$2:C2)-1,COMBIN(COUNTA($A$2:$A$16),2)-COMBIN(COUNTA($A$2:$A$16)+1-ROW(INDIRECT("1:"&COUNTA($A$2:$A$16)-1)),2),ROW(INDIRECT("1:"&COUNTA($A$2:$A$16))))))
D2:D30D2=IF(C2="","",INDEX(INDEX(A$2:A$16,MATCH(C2,A$2:A$16,0)):A$16,COUNTIFS(C$2:C2,C2)+1))
E2:E30E2=IF(C2="","",SUMPRODUCT(--(COUNTIF(OFFSET($G$2:$G$4,0,COLUMN($G$2:$R$2)-COLUMN($G$2)),C2)+COUNTIF(OFFSET($G$2:$G$4,0,COLUMN($G$2:$R$2)-COLUMN($G$2)),D2)=2)))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E:EExpression=E1=MAX(E:E)textNO


The C:D formulas are used to create a list of the pairings. You put the slate of horses in column A. If there are 8 horses in the race, there are 28 possible pairings. Then you'd put in the Tipster picks. Then the formula in column E counts how many times each pairing is found. I added some Conditional Formatting to highlight the pairing(s) that come up most.

Hope this helps!
 
Upvote 0
Solution
hi Eric.
Thank you for the solution.
is there anyway that column A can auto generate the choices made by the tipsters? Rather than me puttingall the ho
 
Upvote 0
That's one reason I said VBA might be better. Try this:

Open a new workbook and set up your worksheet like this:

Book1
ABCDEFGHIJKLM
1RaceTipster 1Tipster 2Tipster 3Tipster 4Tipster 5Tipster 6Tipster 7Tipster 8Tipster 9Tipster 10Tipster 11Tipster 12
21HorseyTableCarPhoneDarkHorseHorseyPhoneTableHorseyBigWinnerBigWinnerBigWinner
31TableHorseyHorseyHorseyTableChairmanTablePhoneSlowpokeSlowpokecarHorsey
41ChairmancarPhoneTableSlowpokePhoneBigleapChairmanTablecarSlowpokePhone
52QuickstepBigLeapMagicPickMeBigLeapPickMeMagicBigLeapFastPonyTooSlowMagic
62FastPonyMagicQuickstepChampQuickstepChampTooSlowMagicTooSlowPickMeBigLeap
72PickMeChampBigLeapTooSlowMagicMagicQuickstepPickMePickMeBigLeapFastPony
83RocketQuasarAsteroidsCometCometMeteorNovaRocketAsteroidsAsteroidsStarQuasar
93StarAsteroidsStarMeteorSputnikRocketRocketMeteorQuasarStarRocketNova
Sheet11



Then Press Alt-F11 to open the VBA editor. Press Alt-IM to Insert a Module. Paste the following code into the sheet that opens:

VBA Code:
Sub RankPairs()
Dim TopLeft As Range, r1 As Long, r2 As Long, r1a As Long, r1b As Long
Dim race As Long, c As Long, d1 As Object, k1 As String

    Set TopLeft = Range("A2")
    
    While TopLeft <> ""
        r1 = TopLeft.Row
        race = TopLeft.Value
        While TopLeft.Value = race
            Set TopLeft = TopLeft.Offset(1)
        Wend
        r2 = TopLeft.Row - 1
        Set d1 = CreateObject("Scripting.Dictionary")
        For c = 2 To 13
            For r1a = r1 To r2 - 1
                For r1b = r1a + 1 To r2
                    If Cells(r1a, c) <> "" And Cells(r1b, c) <> "" Then
                        If LCase(Cells(r1a, c).Value) < LCase(Cells(r1b, c).Value) Then
                            k1 = LCase(Cells(r1a, c).Value) & "/" & LCase(Cells(r1b, c).Value)
                        Else
                            k1 = LCase(Cells(r1b, c).Value) & "/" & LCase(Cells(r1a, c).Value)
                        End If
                        d1(k1) = d1(k1) + 1
                    End If
                Next r1b
            Next r1a
        Next c
        
        If d1.Count > 1 Then
            Cells(r1, "P").Resize(d1.Count) = WorksheetFunction.Transpose(d1.keys)
            Cells(r1, "Q").Resize(d1.Count) = WorksheetFunction.Transpose(d1.items)
            Range("P2:Q19").Select
            With ActiveSheet.Sort
                .SortFields.Clear
                .SetRange Range("P" & r1 & ":Q" & r1 + d1.Count - 1)
                .SortFields.Add2 Key:=Cells(r1, "Q"), Order:=xlDescending
                .Header = xlNo
                .Orientation = xlTopToBottom
                .Apply
            End With
            Cells(r2 + 1, "P").Resize(d1.Count, 2).ClearContents
        End If
    Wend
    
    Range("P2").Select
End Sub

Press Alt-Q to Quit the VBA editor. In Excel, press Alt-F8 to open the macro selector. Select RankPairs and click OK. You should end up with something like this:

Book1
ABCDEFGHIJKLMNOPQ
1RaceTipster 1Tipster 2Tipster 3Tipster 4Tipster 5Tipster 6Tipster 7Tipster 8Tipster 9Tipster 10Tipster 11Tipster 12
21HorseyTableCarPhoneDarkHorseHorseyPhoneTableHorseyBigWinnerBigWinnerBigWinnerhorsey/table4
31TableHorseyHorseyHorseyTableChairmanTablePhoneSlowpokeSlowpokecarHorseyhorsey/phone4
41ChairmancarPhoneTableSlowpokePhoneBigleapChairmanTablecarSlowpokePhonephone/table3
52QuickstepBigLeapMagicPickMeBigLeapPickMeMagicBigLeapFastPonyTooSlowMagicbigleap/magic5
62FastPonyMagicQuickstepChampQuickstepChampTooSlowMagicTooSlowPickMeBigLeapmagic/quickstep3
72PickMeChampBigLeapTooSlowMagicMagicQuickstepPickMePickMeBigLeapFastPonypickme/tooslow3
83RocketQuasarAsteroidsCometCometMeteorNovaRocketAsteroidsAsteroidsStarQuasarrocket/star2
93StarAsteroidsStarMeteorSputnikRocketRocketMeteorQuasarStarRocketNovaasteroids/quasar2
Sheet11
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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