A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
With that many rows, I'm not sure VBA will help, but try this:
Function MyCount(Val1, Val2) As Long
Dim r As Long
Dim m As Long
m = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For r = 5 To m
If Cells(r, 3) =Val1 And Cells(r, 4) > Val2 Then
MyCount = MyCount + 1
End If
Next r
End Function
Use as =MyCount(A5,B5)
If you want the function to recalculate automatically, add a line
Application.Volatile
at the beginning, but this might have a negative impact on performance.