Show user that last modified workbook in a cell on a workbook

mandy4514

New Member
Joined
Apr 20, 2017
Messages
11
I want to show users the last person to save the workbook in the workbook for other users to see. How can I do this?[TABLE="width: 500"]
<tbody>[TR]
[TD]This form was last edited by:[/TD]
[TD](automatically generate name here)[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
press CTRL + F11 keys to open VBE (visual basic editor) top left click ThisWorkbook

put this code in ThisWorkbook module

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

'Sheets("Sheet1").Range("A1").Value = Application.UserName
Sheets("Sheet1").Range("A1").Value = Environ("username")

End Sub

change the sheet and cell reference to your desired location

note i have put a comment line you can choose which username you want saved or can put both in seperate cells

the workbook will need to be saved as macro enabled XLSM
 
Last edited:
Upvote 0
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Sheets("Sheet1").Range("B1").Value = Application.UserName
Sheets("Sheet1").Range("A1").Value = Environ("username")

Sheets("Sheet2").Range("B1").Value = Application.UserName
Sheets("Sheet2").Range("A1").Value = Environ("username")

End Sub

this will put application username in cell B1 and Environment username in cell A1 on both sheet1 and sheet2
 
Upvote 0
So I want one cell to show any change in the entire workbook that contains like 30 sheets that users can edit. Then once I add this code, how do I pull it into a cell?

Thanks for your assistance.
 
Upvote 0
the code i put will place the user name of the person using workbook as it closes

if you tell me the sheet name and the cell you want the name in i can modify the code for that location

if you want it to only activate on save then use before save code instead of on close

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Sheets("Sheet1").Range("B1").Value = Application.UserName
Sheets("Sheet1").Range("A1").Value = Environ("username")

End Sub

if you want to record any change in the workbook with username that is a bit more complicated but can also be done but would require a log sheet to be added

my code saves to sheet1 cell A1 and B1 this can be changed to any sheet and cell .. the username is entered as the workbook closes so will not be visible until you open the workbook again
 
Upvote 0
y4myS-wAC0TcFJ3s4hdExxxiRmo1mVYbowT299jOqXycpmdV13Jr4XdY_3IiP5SaofSTFJSiPS7ZSq_axuVQhAARi_H8exoQpE8EdcbFEvgJMMNBPl0FM3zNTeBqHp6FChZObKa4UZ0GgLXdnD-RwUXygvVlTAMIIdiWDarQdzR1fNmFGR9_WVrlG8UfdSrXoklmYDwCdiAl47YY0sbNZfwDQ
 
Upvote 0
try this code in ThisWorkbook module

i have concatenated both usernames into one string this can be changed

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Sheets("Consolidated Summary").Range("G4").Value = Environ("username") & " " & Application.UserName

End Sub
 
Upvote 0
So I changed to Sub Test() and was able to pull in the info but it is pulling two pieces of info and I only want the full name not the username is this possible?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top