I am trying to create a custom function for %RSD. The formula for %RSD is the (Standard Deviation of a range/Average of the same range)*100. this is normally done in excel by using the STDEV and AVERAGE functions, but I would like a function the will do it by just selecting the range.
Here is the code I have so far, but I keep getting errors.
I am familiar with VBA, but I have never made a custom function. Any help would be appreciated. THANKS!
Code:
=RSD(A1:A6)
Here is the code I have so far, but I keep getting errors.
Code:
Function RSD(rng As Range)
Dim cell As Integer
For Each cell In rng
If cell <> 0 And IsNumeric Then
RSD = ((stdev(rng) / Average(rng)) * 100)
Else
MsgBox ("One or more cells in selected range is blank or not numeric.")
End If
Next cell
End Function