INFO(USER_NAME)

W

Waco

What is the best way of returning a user name or Id to a
cell.

Expected that there nmight be a function simular to.:
=INFO(USER_NAME)
 
C

Chip Pearson

Waco,

You need to use some VBA. For the user name that appears in the Options
dialog, use

Debug.Print Application.UserName

For the logon name, use

Debug.Print Environ("UserName")
' or
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long


Sub AAA()
Dim S As String
Dim L As Long
S = String$(255, " ")
L = 255
GetUserName S, L
S = Left(S, L - 1)
Debug.Print S
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com [email protected]
 
Top