Entering users names in shared workbook

  • Thread starter Thread starter YetAnotherAndy
  • Start date Start date
Y

YetAnotherAndy

I would like to have a shared workbook that will show the users 1st nam
next to a cell which they have to answer yes or no.

This is to allow me to see if an action has been performed, and if s
by whom.

Any help would be much appreciated.

Andy
 
Andy,

You could use the Track Changes function to do this. This adds the username
as a comment, with change details. One problem is that Username under
Options is just a string which can be changed and cannot be relied upon.
Better to rely upon the username that the user logs into the machine with,
and use this value. This simple UDF returns the logged on user name

Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long

Public Function UserName() As String
Dim sName As String * 256
Dim cChars As Long
cChars = 256
If GetUserName(sName, cChars) Then
UserName = Left$(sName, cChars - 1)
End If
End Function

To implement this

Go to the VB IDE (Alt-F11)
Click on the workbook name in the project explorer window (top left of
window)
Click Insert>Module
Paste the code in the code module that opens up
In the project explorer, ensure that the 'Microsoft Excel Objects' section
is expanded (the + sign beside it changes to a -)
Double-click the ThisWorkbook entry
Add this code to that code module

Private Sub Workbook_Open()

Application.UserName = UserName()

End Sub

Go back to Excel and any actions logged on the shared workbook should now
record the logged on user.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top