Hello I am pretty new to excel and was hoping someone could help with this.
I have two columns Column A Has grouped Names and Column B has kinds of Relationships
I need to count all the kinds of Relationships: Self, Boss, Peer, Direct Report, Other for each Name in column A
I can count ALL the Relationships with the Sub below but I can not find or figure out how to count with respect to the name group.
The names constantly change so I can not hard code them
Example
Betty Sue Self(1) Boss(1) Peer(3) Direct Report(1) Other(1)
Thanks
In column A I have "Grouped Names
Betty Sue
Betty Sue
Betty Sue
Betty Sue
Betty Sue
Betty Sue
Fred Anderson
Fred Anderson
Fred Anderson
Molly Capra
Molly Capra
Molly Capra
Molly Capra
Molly Capra
In Column B I have Relationships
Self
Boss
Peer
Peer
Other
Direct Report
Peer
Self
Peer
Direct Report
Direct Report
Direct Report
Boss
My Sub for counting ALL Relationships is
Sub Report()
Dim rng As range
Dim LastRow As Long
Dim iVal As Integer
Dim jVal As Integer
Dim kVal As Integer
Dim lVal As Integer
Dim mVal As Integer
Windows("LimeSurveyTokenTable.xlsx").Activate
With Sheets("sheet1")
LastRow = .range("D" & .Rows.Count).End(xlUp).Row
End With
iVal = Application.WorksheetFunction.CountIf(range("D2:D" & LastRow), "Self")
jVal = Application.WorksheetFunction.CountIf(range("D2:D" & LastRow), "Boss")
kVal = Application.WorksheetFunction.CountIf(range("D2:D" & LastRow), "Peer")
lVal = Application.WorksheetFunction.CountIf(range("D2:D" & LastRow), "Direct Report")
mVal = Application.WorksheetFunction.CountIf(range("D2:D" & LastRow), "Other")
MsgBox "Self'es:" & " " & iVal & " " & "Boss'es:" & " " & jVal & " " & "Peers:" & " " & kVal & " " & "Direct Reports:" & " " & lVal & " " & "Others:" & " " & mVal
End Sub
I have two columns Column A Has grouped Names and Column B has kinds of Relationships
I need to count all the kinds of Relationships: Self, Boss, Peer, Direct Report, Other for each Name in column A
I can count ALL the Relationships with the Sub below but I can not find or figure out how to count with respect to the name group.
The names constantly change so I can not hard code them
Example
Betty Sue Self(1) Boss(1) Peer(3) Direct Report(1) Other(1)
Thanks
In column A I have "Grouped Names
Betty Sue
Betty Sue
Betty Sue
Betty Sue
Betty Sue
Betty Sue
Fred Anderson
Fred Anderson
Fred Anderson
Molly Capra
Molly Capra
Molly Capra
Molly Capra
Molly Capra
In Column B I have Relationships
Self
Boss
Peer
Peer
Other
Direct Report
Peer
Self
Peer
Direct Report
Direct Report
Direct Report
Boss
My Sub for counting ALL Relationships is
Sub Report()
Dim rng As range
Dim LastRow As Long
Dim iVal As Integer
Dim jVal As Integer
Dim kVal As Integer
Dim lVal As Integer
Dim mVal As Integer
Windows("LimeSurveyTokenTable.xlsx").Activate
With Sheets("sheet1")
LastRow = .range("D" & .Rows.Count).End(xlUp).Row
End With
iVal = Application.WorksheetFunction.CountIf(range("D2:D" & LastRow), "Self")
jVal = Application.WorksheetFunction.CountIf(range("D2:D" & LastRow), "Boss")
kVal = Application.WorksheetFunction.CountIf(range("D2:D" & LastRow), "Peer")
lVal = Application.WorksheetFunction.CountIf(range("D2:D" & LastRow), "Direct Report")
mVal = Application.WorksheetFunction.CountIf(range("D2:D" & LastRow), "Other")
MsgBox "Self'es:" & " " & iVal & " " & "Boss'es:" & " " & jVal & " " & "Peers:" & " " & kVal & " " & "Direct Reports:" & " " & lVal & " " & "Others:" & " " & mVal
End Sub