User defined function using a worksheetfunction


Posted by Russell on September 03, 1999 10:16 AM

I'm new at using user defined functions and VBA so please pardon my ignorance. But what is wrong with this simple function (my original function was more complex but I simplified it to help debug)? When using this function I get #VALUE!
Thanks.

Function lq3(inrange)

Dim rkrange As range
Dim count As WorksheetFunction

count (inrange)

lq3 = count
End Function



Posted by Ivan Moala on September 04, 1999 4:41 AM

Russell,
The count (inrange) is not defined ie. you have not defined / assigned it to do anything.
You should define the count eg count = application.worksheetfunction.<your function>
I'm assuming you want to get the count function,
perhaps you should simplfy this as

lq3 = application.worksheetfunction.Count(inrange)

or something ???