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

excel, vba

Solution

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

Problem

I am trying to display the windows user name in a excel cell. How can I do this?

Original source

Related problems