View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld[_2_] Ron Rosenfeld[_2_] is offline
external usenet poster
 
Posts: 1,045
Default User defined function

On Mon, 16 Jan 2012 15:34:40 -0500, GS wrote:

Try:
Function test(num) As String
Select Case num
Case Is 0
test = "Positive"
Case Is = 0
test = "Zero"
Case Is < 0
test = "Negative"
End Select
End Function


You must declare the 'data type' to be returned as shown.


I'm guessing your recommendations are from your background in VB. And it may be that I'm incorrect in how this relates to the OP's problem, but:

With VBA, if you don't declare a return data type, it will be of type Variant and should be OK. So, although it is good practice, it is not necessary and I don't believe it is the reason for his problem.
Also, in VBA, if a Function is not declared as Private, it will be Public. It is usually not necessary to explicitly declare it as Public.