Here is the code for UDF Average_If_Special
Function Average_If_Special(AvgRng As Range, CriRng As Range, Criteria As String)
Dim cel As Range
Dim X As Long, Count1 As Long
Dim Sum1 As Double
X = 1
For Each cel In CriRng
If Not cel.EntireRow.Hidden And cel = Criteria Then
Sum1 = Sum1 + AvgRng.Cells(X, 1)
Count1 = Count1 + 1
End If
X = X + 1
Next cel
If Count1 > 0 Then
Average_If_Special = Sum1 / Count1
End If
End Function
To paste the code
Developer --> Visual Basic
VB window opens.
Insert --> Module
Paste the code.
Close the window.
UDF is available in function list.
Bookmarks