Because there are empty cells in your value column whe have to take this in account for calculation. (previous example had no empty values)
See revised code.
Function CUSTOMAVERAGE(rng As Range, wMonth As Integer)
cP = 0: sP = 0: cR = 0
For Each cell In rng
If Month(cell) = wMonth Then
Total = Total + cell.Offset(, 3).Value: If cell.Offset(, 3) <> vbNullString Then Count = Count + 1
Select Case cell.Offset(, 1).Value
Case "P"
cP = cP + cell.Offset(, 3).Value
Case "p"
sP = sP + cell.Offset(, 3).Value
Case "R"
cR = cR + cell.Offset(, 3).Value
End Select
End If
Next cell
CUSTOMAVERAGE = Round(Total / Count, 1)
End Function
Bookmarks