Iser name

W

wayne

Hi, is there a way that I can find who the active user(s) is/are? ie
Name or staff number etc

TIA
Wayne
 
G

Gord Dibben

You want Excel username or login username?

There is a difference.

Function User()
Application.Volatile
User = Application.UserName 'name in Tools>Options>General
End Function

Function login()
Application.Volatile
login = Environ("Username")
End Function


Gord Dibben MS Excel MVP
 
W

wayne

You want Excel username or login username?

There is a difference.

Function User()
Application.Volatile
User = Application.UserName 'name in Tools>Options>General
End Function

Function login()
Application.Volatile
login = Environ("Username")
End Function


Gord Dibben MS Excel MVP

The 2nd one is the one for me sir. All I need now is to be able to
record/saxe the username of whoever opened/closed the sheet lasr.

Any hlep greatly appreciated
 
G

Gord Dibben

Place this code in Thisworkbook module.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
With Worksheets("Sheet1")
.Range("A1").Value = "Last Saved By " _
& Environ("UserName") & " " & Now
End With
.Save
End With
End Sub

Or if you want a permanent record in a list use the following instead.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim lastrow As Range
With ThisWorkbook
With Worksheets("Sheet1")
Set lastrow = .Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
lastrow.Value = "Last Saved By " _
& Environ("UserName") & " " & Now
End With
.Save
End With
End Sub


Gord
 
W

wayne

Place this code in Thisworkbook module.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
With Worksheets("Sheet1")
.Range("A1").Value = "Last Saved By " _
& Environ("UserName") & " " & Now
End With
.Save
End With
End Sub

Or if you want a permanent record in a list use the following instead.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim lastrow As Range
With ThisWorkbook
With Worksheets("Sheet1")
Set lastrow = .Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0)
lastrow.Value = "Last Saved By " _
& Environ("UserName") & " " & Now
End With
.Save
End With
End Sub


Gord


That's just fantastic. Superlatives fail me. MVP is a real
understatement

any,many thanks
wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top