ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Auto Updating the Logged in User (https://www.excelbanter.com/excel-discussion-misc-queries/156960-auto-updating-logged-user.html)

DCHims

Auto Updating the Logged in User
 
I am using a some excel sheets located on a network server and would like to
make it so one of the fields lists the logged in user as soon as the sheet is
open. I found this VBA Macro in one of the past posts:

Function UserName()
UserName = Environ("UserName")
End Function

This function displays the user but does not auto update when I open the
sheet. I have to double click on the name for it to update the user.

Jim Thomlinson

Auto Updating the Logged in User
 
Give this a try...

Function UserName()
Application.Volatile
UserName = Environ("UserName")
End Function

Note that this function is volatile so it will update every time any
calculation is run which gives it a bit of overhead... Probably not a big
deal in this case.
--
HTH...

Jim Thomlinson


"DCHims" wrote:

I am using a some excel sheets located on a network server and would like to
make it so one of the fields lists the logged in user as soon as the sheet is
open. I found this VBA Macro in one of the past posts:

Function UserName()
UserName = Environ("UserName")
End Function

This function displays the user but does not auto update when I open the
sheet. I have to double click on the name for it to update the user.



All times are GMT +1. The time now is 02:44 PM.

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