Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

How can I do this?

like image 275
Ranjit Kumar Avatar asked Nov 16 '12 07:11

Ranjit Kumar


People also ask

How do I AutoFill a username in Excel?

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.

What is the fastest way to add a Windows name to a cell in Excel?

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.


Video Answer


1 Answers

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
like image 195
CustomX Avatar answered Oct 10 '22 11:10

CustomX