How To Count Paired Data

2blues

New Member
Joined
Apr 25, 2018
Messages
7
Hey Guys,

Having trouble solving this one. I have data that is displayed like this:

England 4
France 3

Brazil 4
USA 4

USA 4
Canada 3

I'm trying to count how many times a combo of England,France occurred as a 4/3, Brazil, USA as a 4/4 and so on...the data is displayed vertically unfortunately. The numbers can vary (4/2, 5/3, 4,1 for ex) but it will always be a combo of 2 names. The two names and sets of numbers can occur multiple times or just once.

Thanks




<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Are the names in different rows?
 
Upvote 0
Are the names in different rows?

Yes so it looks like this with cell numbers for example:

A1 B1
England 4
A2 B2
London 3

There is also an empty row after each pair, however if that is an issue I can always delete the empty rows so they follow one after another.
 
Upvote 0
Try this

Code:
Dim Aloop As Integer
Dim LastRowNo As Integer
Dim Team1 As String
Dim Team2 As String
Dim Combo As Integer


Sub FindCombo()
LastRowNo = Range("A65536").End(xlUp).Row 'Just to set list of names
If LastRowNo <= 1 Then Exit Sub


' Just so the tea names can be changed
' else set Team1 = "England", Team2 = "France"
Team1 = Range("E2").Value
Team2 = Range("F2").Value
Combo = 0


For Aloop = 2 To LastRowNo Step 3
        If Range("A" & Aloop).Value = Team1 And Range("A" & Aloop + 1).Value = Team2 Then
            Combo = Combo + 1
        End If
Next Aloop


Range("G2").Value = Combo
End Sub

I put these in the rows and columns shown. ALternately you could enter the names directly as mentioned in the code.

E F G
1 Team 1 Team 2 Combination
2 England France
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,613
Members
449,238
Latest member
wcbyers

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