View Full Version : Solved: Usernname in a cell
u25103
10-08-2008, 01:37 AM
Hi
I need to get the username in a cell.
I have a workbook that has many user, if there has been several printout I want to see witch user that made the printout.
:dunno
georgiboy
10-08-2008, 01:45 AM
Is this what you mean
Sub UserName()
Sheet1.Range("A1").Value = Application.UserName
End Sub
hope this helps
u25103
10-08-2008, 02:07 AM
Thanks
But...
If a new user open this sheet a want it to show (username" directly in range A1. The other users do not run the cod.
georgiboy
10-08-2008, 02:09 AM
You will need to put this code in an auto open macro like this
Sub Auto_Open()
Sheet1.Range("A1").Value = Application.UserName
End Sub
that way it will run automaticaly when the sheet is opened
hope this helps
u25103
10-08-2008, 02:46 AM
Thank you
it works
One last question.....
How can I change the cod, If I want the "Auto_open" sub work on every sheet in the workbook.
Hi, you will need to copy/paste the following into the Workbook 'module' on the left of the Visual Basic Editor screen...
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ActiveSheet.Range("A1").Value = Application.UserName
End Sub
This will action the code for any worksheet that is activated in the workbook.
u25103
10-08-2008, 03:02 AM
Thank you
It works perfectly
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.