Mode function using WorksheetFunction produces error

GKIL67

Registered User.
Local time
Today, 21:04
Joined
Apr 28, 2011
Messages
24
If I use
Code:
?WorksheetFunction.Mode(Array(1,2,5,8,12,13,1,1))
it works OK, but the following function gives the Error "Unable to get the Mode property of the Worksheetfunction class".
Code:
Function Mode(strString As Variant)
'?Mode("1,2,5,8,12,13,1,1")
Dim VarOut As Variant

VarOut = Array(Split(strString, ","))
Mode = WorksheetFunction.Mode(VarOut)

End Function
Can somebody help to solve it out?
Thank you in advance!
 
Solved. It should be:
Code:
Function Mode(ParamArray dblNos()) As Double
'?Mode(1,2,5,8,12,13,1,1) returns 1.

Mode = WorksheetFunction.Mode(Array(dblNos))

End Function
 

Users who are viewing this thread

Back
Top Bottom