User-Defined function not working

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
..
 
A

Alex@JPCS

Guy,
If you are trying to put the value of this function into a cell on a sheet,
then make sure that the cell formula is

=User()

By the way, I usually prefer to name my custom functions something like
ufUser (for "User Function") just in case "User" is a reserved name in
Excel.

Salut,

Alex@JPCS
 
T

Tom Ogilvy

Make sure the function is in a general module and not in a worksheet module
or the ThisWorkbook module.

As long as macros are enabled, should work.


Regards,
Tom Ogilvy
 
G

Guy Gagnon

Thanks for the tip. The problem I was having weas the
code was not in a General module rather it was in the
worksheet.

Cheers,
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