Adding the username at login to an excel cell

Schwick

New Member
Joined
Mar 16, 2004
Messages
5
Does anyone know how to add the login name to a cell in excel.
I am actually wanting to add it to a database, but figure that if I can find the code to add it to excel then the rest should be relatively easy.

Here is what I am using so far with no luck of it working.

Private Sub Workbook_Open()
If [G6].Value <> "" Then Exit Sub
[G6].Value = EnvironUserName() End Sub

It examines cell g6 on open and if it is blank I would like it to read the login name of the person opening the workbook or sheet.

If anyone has some ideas or thoughts they would be greatly appreciated.

Thanks In Advance,
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

btadams

Well-known Member
Joined
Jan 6, 2003
Messages
1,936
you were close:

If [G6].Value <> "" Then Exit Sub
[G6].Value = Environ("UserName")


P.S. Not from Cedar Rapids, are you?
 

Watch MrExcel Video

Forum statistics

Threads
1,119,002
Messages
5,575,499
Members
412,670
Latest member
Khin Zaw Htwe
Top