tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,194
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I have this function i use a lot,
which allows me to get a log average over a range,
I'm woundering if it would be possible to change it so it gives the log average over the range of cells that match the cell next to it, (Like sumif and countif do)
so instead of just
=LogAverage(C26:C500)
Maybe
in C2 it would read
=LogAverageIf(A26:A500,A2,C26:C500) (With A2 being the critiria and A26:A500, the criteria range)
please help if you can
Thanks
Tony
I have this function i use a lot,
VBA Code:
Function LogAverage(ParamArray AveCells() As Variant) As Double
Dim out As Double
Dim cel As Range
Dim count, i As Long
count = 0
out = 0
For i = LBound(AveCells) To UBound(AveCells)
If TypeName(AveCells(i)) = "Range" Then
For Each cel In AveCells(i)
If IsEmpty(cel) Then
'skip blank cells
Else
out = out + 10 ^ (cel.Value / 10)
count = count + 1
End If
Next cel
Else
If IsEmpty(AveCells(i)) Then
'skip blank cells
Else
out = out + 10 ^ (AveCells(i) / 10)
count = count + 1
End If
End If
Next i
LogAverage = 10 * Log(out / count) / Log(10)
End Function
which allows me to get a log average over a range,
I'm woundering if it would be possible to change it so it gives the log average over the range of cells that match the cell next to it, (Like sumif and countif do)
so instead of just
=LogAverage(C26:C500)
Maybe
in C2 it would read
=LogAverageIf(A26:A500,A2,C26:C500) (With A2 being the critiria and A26:A500, the criteria range)
please help if you can
Thanks
Tony