I am trying to display the windows user name in a excel cell.
How can I do this?
Click and hold the left mouse button, and drag the plus sign over the cells you want to fill. And the series is filled in for you automatically using the AutoFill feature. Or, say you have information in Excel that isn't formatted the way you need it to be, such as this list of names.
1. Press Alt + F11 keys to enable Microsoft Visual Basic for Applications window, click Insert > Module, then copy and paste below VBA code to the Module window. VBA: Insert username. You can change the range A1: D5 in VBA code to meet your need.
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 >SystemIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With