ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Show username in a cell (https://www.excelbanter.com/excel-discussion-misc-queries/92153-show-username-cell.html)

bradasley

Show username in a cell
 
How can I get a username to appear in a cell?

Thanks

David

CLR

Show username in a cell
 
With code........change the A1 as desired......

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

Vaya con Dios,
Chuck, CABGx3



"bradasley" wrote:

How can I get a username to appear in a cell?

Thanks

David


Chip Pearson

Show username in a cell
 
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


"bradasley" wrote in
message
...
How can I get a username to appear in a cell?

Thanks

David




Don Guillett

Show username in a cell
 
look here
http://tinyurl.com/qqsm8
or
editnamedefinename it whatever you like such as ws
in the refers to box type =get.workspace(26)ok

then, in a cell, just type in =ws

--
Don Guillett
SalesAid Software

"bradasley" wrote in message
...
How can I get a username to appear in a cell?

Thanks

David




CLR

Show username in a cell
 
How cool that is Don!!..................a keeper here.

Vaya con Dios,
Chuck, CABGx3



"Don Guillett" wrote:

look here
http://tinyurl.com/qqsm8
or
editnamedefinename it whatever you like such as ws
in the refers to box type =get.workspace(26)ok

then, in a cell, just type in =ws

--
Don Guillett
SalesAid Software

"bradasley" wrote in message
...
How can I get a username to appear in a cell?

Thanks

David






All times are GMT +1. The time now is 02:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com