
Use a user-defined function to determine the
current user of Windows or Excel
This tip explains how to determine the current user of Windows
and/or Excel. Once again, you will write a user-defined function. In
this case, the function will return the name of the current user.
4
To get the current Windows user:
1. Press <Alt+F11> to open up the Visual Basic Editor.
2. From the Insert menu, click Module.
3. Type the following function:
Function User()
User = Environ("Username")
End Function
4. Close the VBA Editor and type the following formula in any
cell: =User().
5. Press <Enter>.
4
To get the current Excel user:
1. Press <Alt+F11> to open up the Visual Basic ...