ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Refresh Code Question (https://www.excelbanter.com/excel-programming/360370-refresh-code-question.html)

~C

Refresh Code Question
 
I have the following code in a spreadsheet:

Function NetworkUserName() As String
Dim response
NetworkUserName = Environ("Username")
Application.Volatile
End Function


I have placed this worksheet on our company network so that many people can
access it. However, it saves my username and does not refresh to display the
current user's information unless they go to that cell and press Enter. How
can I get it to refresh when the file is opened?

Thanks!

~C

Bob Phillips[_14_]

Refresh Code Question
 
'-----------------------------------------------------------------
Private Sub Workbook_Open()
'-----------------------------------------------------------------
Worksheets("Sheet1").Range("A1").Value = Environ("Username")
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"~C" wrote in message
...
I have the following code in a spreadsheet:

Function NetworkUserName() As String
Dim response
NetworkUserName = Environ("Username")
Application.Volatile
End Function


I have placed this worksheet on our company network so that many people

can
access it. However, it saves my username and does not refresh to display

the
current user's information unless they go to that cell and press Enter.

How
can I get it to refresh when the file is opened?

Thanks!

~C





All times are GMT +1. The time now is 11:28 AM.

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