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,
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

btadams

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

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


P.S. Not from Cedar Rapids, are you?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,502
Messages
5,832,099
Members
430,111
Latest member
Francis Xavier

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top