UDF, Type it or use Insert Function

  • Thread starter Thread starter Otto Moehrbach
  • Start date Start date
O

Otto Moehrbach

Excel 2002, Win XP
I remember being told in the past that a UDF must be entered using the
function wizard (Insert Function dialog box) and that typing the function
into a cell would not work.
I have 3 UDFs below. The 3rd one uses the first 2. During development,
I was able to utilize either of the first 2 by typing them into a cell
manually. The 3rd one, no. The 3rd one required the function wizard to
make it work.
What is the rule that allows the first 2 to work (by typing direct) and
the 3rd one to require the function wizard. Thanks for your help as always.
For your information, this has to do with the military 8 digit date
format. Otto
Function DateFrom8(j As Range) As Date
DateFrom8 = DateSerial(Left(j, 4), Mid(j, 5, 2), Right(j, 2))
End Function

Function DateTo8(i As Date) As String
DateTo8 = Year(i) & _
IIf(Len(Month(i)) > 1, Month(i), "0" & Month(i)) & _
IIf(Len(Day(i)) > 1, Day(i), "0" & Day(i))
End Function

Function IncDate(k As Range) As String
Dim TheDate As Date
TheDate = DateFrom8(k)
'The "5" in the following line is actually a calculated variable.
'The "5" is used here for development purposes only'
TheDate = _
DateSerial(Year(TheDate), Month(TheDate) + 5, Day(TheDate))
IncDate = DateTo8(TheDate)
End Function
 
who ever told you that was obviously wrong.

I entered all three by typing them in and had no problem.

I rarely use the function wizard to enter anything. I have never found it
was necessary.

Regards,
Tom Ogilvy
 
Mostly the difference is that the function wizard uses EVALUATE (I think) ro
evaluate each keystroke as it goes along.

hth
Charles
______________________
Decision Models
The Excel Calculation Site

www.DecisionModels.com
 
I believe one of the advantages of using the function wizard is that it will
put the name of the Workbook in front of the Function. This helps when
calling a function in another workbook, or perhaps when the same function
name exists in two different workbooks. For example, it saves typing when
calling a function located in Personal.xls.

=Personal.xls!YourFunction( )
 
Back
Top