1 year ago
#76096
Bryce Eisner
function for average of visible data on filtered table
FUNCTION_TABLE_ARRAY_AVERAGE(Rg As Range)
'Trying to get average of filtered cells
Dim xCell As Range
Dim xCount As integer
Dim xTtl As variant
Application.Volatile
Set Rg = Intersect(Rg.Parent.UsedRange, Rg)
For Each xCell In Rg
If xCell.ColumnWidth > 0 _
And xCell.RowHeight > 0 _
And Not IsEmpty(xCell) _
And IsNumeric(xCell.Value) Then
xTtl = xTtl + xCell.Value
xCount = xCount + 1
End If
Next
If xCount > 0 Then
AverVisible = xTtl / xCount
Else
AverVisible = 0
End If
End Function
I'm looking to have this function calculate the average of a fraction or decimal or whole number in the column i select on a filtered table.
excel
vba
filter
average
visible
0 Answers
Your Answer