Problem with UDF

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to implement some simple UDFs in VBA. I programmed the UDF but Excel doesn't appear to recognize their existence fully.

I get #Name? in the cell and the UDF does not show up in the function list nor does any indication of user defined functions. I copies a simple example from the web to calculate the area of a rectangle with the same result. Excel knows that it exists because when Excel starts it asks if I want to enable marcos and it shows up on the object browser. I was under the impression that once you write a UDF in VBA, it is immediately available. What am I doing wrong?

An example is:

Public Function pfd(Llambda As Double, test_interval As Double) As Double

pfd = 1 - Exp(-Llambda * test_interval / 2)

End Function

The function is in the ThisWorkBook module.

Thanks ahead of time for any help.

Bill Mostia
 
UDF must be in a REGULAR module, not a ThisWorkbook or sheet module.

--
Don Guillett
SalesAid Software
(e-mail address removed)
wlmostia said:
I need to implement some simple UDFs in VBA. I programmed the UDF but
Excel doesn't appear to recognize their existence fully.
I get #Name? in the cell and the UDF does not show up in the function list
nor does any indication of user defined functions. I copies a simple
example from the web to calculate the area of a rectangle with the same
result. Excel knows that it exists because when Excel starts it asks if I
want to enable marcos and it shows up on the object browser. I was under
the impression that once you write a UDF in VBA, it is immediately
available. What am I doing wrong?
 
Bill

Move the Function to a General Module.

Insert>Module and paste in there.

Gord Dibben Excel MVP
 
Back
Top