doing average
Posted: Sun May 30, 2021 1:13 pm
Hi Dear!
I have written a macro in form of custom function to average cells base on red color font.
I checked code right but why not calculate right?
What's wrong ,any matter will share file
Best Wishes,
I have written a macro in form of custom function to average cells base on red color font.
I checked code right but why not calculate right?
Code: Select all
Function AverageRed(rng As Range)
Dim C As Range
Dim Count As Long
Dim Result As Double
For Each C In rng
If C.Font.ColorIndex=3 And IsNumeric(C.Value) Then
Result = Result + C.Value
Count = Count + 1
End If
Next
If Count = 0 Then
AverageRed = ""
Else
AverageRed = Result / Count
End If
End FunctionBest Wishes,