Adding timestamp of recent changes on any cell within a row

boboyad

New Member
Joined
Sep 11, 2023
Messages
7
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I saw this code before on another post

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Target.Row < 8 Then Exit Sub
If Target.Column > 43 Then Exit Sub
Cells(Target.Row, "AR") = Date
End Sub

This works perfectly. However I also want to show the time and which cell in that row was modified.

Thanks!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
welcome to the forum, try this;
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Target.Row < 8 Then Exit Sub
If Target.Column > 43 Then Exit Sub
Cells(Target.Row, "AR") = Now()
Cells(Target.Row, "AS") = Target.Address


End Sub
Note I haven't formated column AR since you can format just for the time , just the date or date and time
 
Upvote 1
You're a godsend!!
Sorry if it's too much to ask but is it possible to add the user as well?
 
Upvote 0
Yes you can just add this line to the end of the code ( before the END sub):
VBA Code:
Cells(Target.Row, "AT") = Application.UserName
 
Upvote 1
Yes you can just add this line to the end of the code ( before the END sub):
VBA Code:
Cells(Target.Row, "AT") = Application.UserName
I don't know about you, but on my computer:
VBA Code:
 Application.UserName
returns "Microsoft".

To get my logged in UserName, I need use:
VBA Code:
Environ("UserName")
 
Upvote 1
I don't know about you, but on my computer:
VBA Code:
 Application.UserName
returns "Microsoft".

To get my logged in UserName, I need use:
VBA Code:
Environ("UserName")
Would this work in organisational computers?

Should I type:
Cells(Target.Row, "AT") = Environ("Username")
 
Upvote 0
Interesting because On mine it returns my Microsoft account name!! , This could be because I operate on 2010 not 365!!
Eviron("Username") returns the user name which I use to log into the computer ( which is not the same because I use a local account)
 
Upvote 0
Would this work in organisational computers?

Should I type:
Cells(Target.Row, "AT") = Environ("Username")
I am on a work network myself.
Just use whichever one gives you your desired results.
 
Upvote 0
Interesting because On mine it returns my Microsoft account name!! , This could be because I operate on 2010 not 365!!
Are you on a home PC or work network?
 
Upvote 0

Forum statistics

Threads
1,215,108
Messages
6,123,129
Members
449,097
Latest member
mlckr

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