Hi everyone. This is a continuation to the filter I brought up before. So I got it to work, filtering based on individual,
but now what i'm trying to do is filter based on groups. Here is what I mean:
What I'm trying to do is have each individual filtered under grade 19 populated in the listbox only once, than have the total amount of training and training hours summed up.
However, I'm not quite sure how to go about this. I thought of doing this through countifs (code below is only countif)
However, I realized the filter criteria is based on the combobox value, which only refers to the grade. In this case, i'm not sure how to refer to the name cell (as it runs through the loop).
I also tried adding c = c + 1, code runs but with no difference. Appreciate all help I can get. Please and thank you.
but now what i'm trying to do is filter based on groups. Here is what I mean:
What I'm trying to do is have each individual filtered under grade 19 populated in the listbox only once, than have the total amount of training and training hours summed up.
However, I'm not quite sure how to go about this. I thought of doing this through countifs (code below is only countif)
VBA Code:
Private Sub cmbGred_Change()
Sheet1.Activate
Me.ListBox1.Clear
Me.ListBox1.AddItem
For a = 1 To 3
Me.ListBox1.List(0, a - 1) = Sheet1.Cells(1, a)
Me.ListBox1.List(0, 3) = "Total amount of Training"
Me.ListBox1.List(0, 4) = "Total Training hours"
Next a
Dim My_range As Integer
Dim Column As Byte
For k = 2 To Sheet1.Range("A100000").End(xlUp).Offset(1, 0).Row
c = Application.WorksheetFunction.CountIf(Sheet1.Range("b" & k), Me.cmbGred)
If CStr(Sheet1.Cells(k, 2)) = CStr(Me.cmbGred) And c = 1 Then
'if cell matches combobox value and if duplicate is found via count if
Me.ListBox1.AddItem
My_range = My_range + 1
For Column = 1 To 3
Me.ListBox1.List(My_range, Column - 1) = Sheet1.Cells(k, Column)
D = cmbGred.Value
Me.ListBox1.List(1, 3) = Application.WorksheetFunction.CountIf(Sheet1.Range("A:A"), D)
Next Column
End If
Next k
End Sub
However, I realized the filter criteria is based on the combobox value, which only refers to the grade. In this case, i'm not sure how to refer to the name cell (as it runs through the loop).
I also tried adding c = c + 1, code runs but with no difference. Appreciate all help I can get. Please and thank you.