VBA help - Showing Username of Person Updating Spreadsheet

Necroscope

Board Regular
Joined
Jul 7, 2004
Messages
72
Hi.

I have a Userform that some users complete to update info on a (large) table. I've added a bit of VBA to get the date added when the user who has opened the spreadsheet makes a change to the database but I'd like to be able to add their name too.

However, when I use Application.Username I get the full Global Address List name of that user (i.e. Smith John Sales Team Manager). When I use Environ("username") I get the user's 8-digit staff number.

What I'd like to display is "John Smith"... Anyone know if this is possible?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

NoSparks

Well-known Member
Joined
Mar 15, 2013
Messages
1,051
Office Version
  1. 2010
Platform
  1. Windows
perhaps something like this
Code:
Sub testing()
    Dim excelUserName As String, usr
    
excelUserName = Application.UserName

If InStr(excelUserName, " ") Then
    usr = Split(excelUserName, " ")
    MsgBox usr(1) & " " & usr(0)
Else
    MsgBox excelUserName
End If

End Sub
 

Necroscope

Board Regular
Joined
Jul 7, 2004
Messages
72
Hi NoSparks.

That works perfectly. Thank you very much for taking the time to reply.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,174
Messages
5,640,593
Members
417,152
Latest member
DayTimeSeby

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