Show username in a cell

  • Thread starter Thread starter Guest
  • Start date Start date
With code........change the A1 as desired......

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

Vaya con Dios,
Chuck, CABGx3
 
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]...
 
How cool that is Don!!..................a keeper here.

Vaya con Dios,
Chuck, CABGx3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top