User Defined Function in VBA do not work in Excel

G

Guy Gagnon

I am trying to get a user defined functione to work in
excel and all I get is #NAME. I am using Office XP (Excel
2002)

I have simplified the function to a minimum (here is the
code):

Public Function User()
' Returns the name of the current User
User = Application.UserName
End Function


I have tried the following:

- Set Macro security to Medium and then to low.
- Digitally signed the code using a key generated by
SELFCERT.exe
- Everytime I have changed the secucrity settings I save
the spreadsheet, closed it and re-opened it.

So far nothing works can anyone offer some insight?

Thanks
 
R

Ron Rosenfeld

I am trying to get a user defined functione to work in
excel and all I get is #NAME. I am using Office XP (Excel
2002)

I have simplified the function to a minimum (here is the
code):

Public Function User()
' Returns the name of the current User
User = Application.UserName
End Function


I have tried the following:

- Set Macro security to Medium and then to low.
- Digitally signed the code using a key generated by
SELFCERT.exe
- Everytime I have changed the secucrity settings I save
the spreadsheet, closed it and re-opened it.

So far nothing works can anyone offer some insight?

Thanks

It works fine for me.

You may have some kind of naming issue.

Is the UDF in the same module as your current workbook?
Have you looked in the User section of the formula list to see if it is there?
If there is some naming conflict, or if the UDF is not in the active workbook
or an add-in, then the name of the workbook and possibly the module may need to
be spelled out.


--ron
 
G

Guy Gagnon

-----Original Message-----
It works fine for me.

You may have some kind of naming issue.

Is the UDF in the same module as your current workbook?
Have you looked in the User section of the formula list to see if it is there?
If there is some naming conflict, or if the UDF is not in the active workbook
or an add-in, then the name of the workbook and possibly the module may need to
be spelled out.


--ron
.

Thanks, the code was under the Sheet1 part of the Excel
Objects, I did not realize it needed to be in a Module.

Appreciate the help.
Guy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top