My suggestion is VBA - Your last attachment.
Sub CountIF_()
Dim a(), mth()
Dim i As Integer, j As Integer, lr As Integer
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With ThisWorkbook.Sheets("Sheet1")
lr = .Cells(Rows.Count, "A").End(xlUp).Row
a = .Range("A2:C" & lr).Value
lr = .Cells(Rows.Count, "E").End(xlUp).Row
.Range("E2:H" & lr).Offset(0, 1).ClearContents
mth = .Range("E2:H" & lr).Value
For j = 1 To UBound(mth)
For i = 1 To UBound(a)
If Month(a(i, 1)) = Month(mth(j, 1)) And Year(a(i, 1)) = Year(mth(j, 1)) Then
If Not d.exists(a(i, 2)) Then
d(a(i, 2)) = a(i, 3)
mth(j, 2) = mth(j, 2) + 1
mth(j, 3) = mth(j, 3) + IIf(UCase(a(i, 3)) = "PASS", 1, 0)
mth(j, 4) = mth(j, 4) + IIf(UCase(a(i, 3)) = "FAIL", 1, 0)
End If
End If
Next
Next
.[E2].Resize(UBound(mth), UBound(mth, 2)) = mth
End With
Set d = Nothing
End Sub
Greetings.
Bookmarks