Use Excel VBA to Get Username of Person Logged in to Computer

Using Excel VBA you can get the username of the person logged into the computer and print it to a cell.

I have used this before to monitor which users on a network where accessing a staff performance system. I won’t publish the full code, but just the section that gets the username.

So, the code below would be entered as a new module. Note, it is just one line of code to get the name and print to the cell.

Public Sub Get_UserName()

Cells(1,1) = Application.UserName

End Sub

You could add in an extra line of code to then get the computer name of the computer the person is using.

Leave a Reply

Your email address will not be published. Required fields are marked *