[vba] How can I display my windows user name in excel spread sheet using macros?

I am trying to display the windows user name in a excel cell.

How can I do this?

This question is related to vba excel

The answer is


Range("A1").value = Environ("Username")

This is better than Application.Username, which doesn't always supply the Windows username. Thanks to Kyle for pointing this out.

  • Application Username is the name of the User set in Excel > Tools > Options
  • Environ("Username") is the name you registered for Windows; see Control Panel >System