View Single Post
  #19   Report Post  
Harlan Grove
 
Posts: n/a
Default

Tushar Mehta wrote...
....
. . . Nonetheless, if you do want to do down this road, you
can still leverage the XL object model. Untested code:

Public Function RSD(ParamArray X() As Variant)
With Application.WorksheetFunction
RSD = .StDev(X) / .Average(X) * 100
End With
End Function


You didn't tortute test this. With A1:B2 containing {1,2;3,4},

=RSD(A1:B2) returns #VALUE!

=RSD({1,2},{3;4}) returns #VALUE!

=RSD({1;2}) returns #VALUE!

The problem is with the functions called via
Application.WorksheetFunctions. Those functions can handle ParamArray
arrays only in very limited situations. Either all arguments must be
simple numbers (scalars) or all simple horizontal arrays of the same
size. These functions can't even handle a single range argument if it's
wrapped as a ParamArray.