Excel function to return user name

General Ledger

Active Member
Joined
Dec 31, 2007
Messages
460
Dear All,

I am looking for an Excel 2003 function to return the user's name to a cell.

If not a function, option two would be VBA to return the user's name to a cell.

Thanks,

GL
 
I believe VBA is the only way to go here. Try:

Code:
Function GetUser()
GetUser = Environ("UserName")
End Function

Returns currently logged in window's username.
 
Upvote 0
The function works great. My only issue is it seems to pull the user name from the operating system. I was hoping to pull the user name from within Excel.

In Excel 2003, this is setup under Tools > Options > General This would be the same user name used by Excel when you insert a comment.

I tried but get an error with:
Sub GetUser()
Range("B3").Value = Application("UserName")
End Sub
 
Upvote 0
PERFECT!!!

To return user name from Excel:

Sub GetUser()
Range("B3").Value = Application.UserName
End Sub


To return user name from operating system:

Sub GetUser()
Range("B3").Value = Environ("UserName")
End Sub

Thanks dscg and Oaktree!
 
Upvote 0
Pauljj

Or:

Code:
Sub getuser()
[b3] = Application.UserName
End Sub

if you want to type even less.

Wigi
 
Upvote 0
Well I didn't know that Wigi, thanks, always good to know where you can save key strokes

Thanks for that
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top