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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
you were close:

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


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

Forum statistics

Threads
1,215,022
Messages
6,122,716
Members
449,093
Latest member
Mnur

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
Back
Top