Show username in a cell

C

CLR

With code........change the A1 as desired......

Sub username()
Range("A1").Value = ThisWorkbook.BuiltinDocumentProperties("author")
End Sub

Vaya con Dios,
Chuck, CABGx3
 
C

Chip Pearson

To get the user's logon name, use a VBA function like

Declare Function GetUserName Lib "advapi32.dll" Alias
"GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long


Function GetLogonName() As String
Dim N As Long: N = 255
Dim S As String
S = String(N, " ")
GetUserName S, N
GetLogonName = Left(S, N - 1)
End Function

You can then call this from a cell with =GetLogonName()

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


message
news:[email protected]...
 
C

CLR

How cool that is Don!!..................a keeper here.

Vaya con Dios,
Chuck, CABGx3
 
Top