RE: How can I display a user name is Excel?

G

Gary''s Student

Try this User Defined Function:

Function username() As String
username = Environ("username")
End Function


UDFs are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the UDF will be saved with it.

To use the UDF from the normal Excel window, just enter it like a normal
Excel Function

To remove the UDF:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To learn more about UDFs, see:

http://www.cpearson.com/excel/WritingFunctionsInVBA.aspx
 
Joined
Mar 3, 2010
Messages
1
Reaction score
0
My point in using this is so that when each user logs in it changes to their username, but when I use this function '=username()' it does not automatically refresh to the current user's name when they log in.

Is there something else I need to do to get that to happen automatically?

Thanks!
 

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