ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reference a User Name via macro (https://www.excelbanter.com/excel-programming/335441-reference-user-name-via-macro.html)

PCLIVE

Reference a User Name via macro
 
What code should I use to reference the current user that is saved within
Excel. When the macro is run, in A2 I would like it to display the user
that ran the macro

Range("A2").Value = current user name

Thanks,
Paul



Tom Ogilvy

Reference a User Name via macro
 
Range("A2").Value = environ("username")

or perhaps you are looking for application.Username which is what is entered
in Tools=Options=General tab

--
Regards,
Tom Ogilvy


"PCLIVE" wrote in message
...
What code should I use to reference the current user that is saved within
Excel. When the macro is run, in A2 I would like it to display the user
that ran the macro

Range("A2").Value = current user name

Thanks,
Paul





Gixxer_J_97[_2_]

Reference a User Name via macro
 
Range("A2").Value = Environ("UserName")
should work



"PCLIVE" wrote:

What code should I use to reference the current user that is saved within
Excel. When the macro is run, in A2 I would like it to display the user
that ran the macro

Range("A2").Value = current user name

Thanks,
Paul




PCLIVE

Reference a User Name via macro
 
Tom,

Thank you. You have covered both areas, one of which I will definitely use.
After testing each method you've suggested, I will most likely use
environ("Username"). After testing this I'm assuming that this is pulling
from the "Computer Name" set in Device Manager.

Thanks again for your help.
Paul


"Tom Ogilvy" wrote in message
...
Range("A2").Value = environ("username")

or perhaps you are looking for application.Username which is what is
entered
in Tools=Options=General tab

--
Regards,
Tom Ogilvy


"PCLIVE" wrote in message
...
What code should I use to reference the current user that is saved within
Excel. When the macro is run, in A2 I would like it to display the user
that ran the macro

Range("A2").Value = current user name

Thanks,
Paul








All times are GMT +1. The time now is 12:18 PM.

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