Timestamp on worksheet change

nparsons75

Well-known Member
Joined
Sep 23, 2013
Messages
1,254
Office Version
  1. 2016
Hi,

I have two worksheets

  1. sheet 1
  2. sheet 2

In sheet 1 I a have two cells that I would like to autofil with username and timestamp when data is changed on sheet 2.

A1 = username
A2 = timestamp


If anything changes on sheet 2 I need A1 and A2 to have the username and timestamp automatically added. The aim is to see when sheet 2 was last updated.

Thank you in advance.
 
Not sure I'm entirely clear on the requirement but see if this helps. It will record when any change is made within the range you indicated.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, c As Range
  
  Set Changed = Intersect(Target, Columns("V"), Rows("4:" & Rows.Count))
  If Not Changed Is Nothing Then
    Application.EnableEvents = False
    For Each c In Changed
      c.Offset(, 3).Value = Environ("username")
      c.Offset(, 4).Value = Now
    Next c
    Application.EnableEvents = True
  End If
End Sub
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Not sure I'm entirely clear on the requirement but see if this helps. It will record when any change is made within the range you indicated.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, c As Range
  
  Set Changed = Intersect(Target, Columns("V"), Rows("4:" & Rows.Count))
  If Not Changed Is Nothing Then
    Application.EnableEvents = False
    For Each c In Changed
      c.Offset(, 3).Value = Environ("username")
      c.Offset(, 4).Value = Now
    Next c
    Application.EnableEvents = True
  End If
End Sub





Thanks for this, i will give it a try and report back any issues. once again thank you for all your help so far
Ross
 
Upvote 0
Not sure I'm entirely clear on the requirement but see if this helps. It will record when any change is made within the range you indicated.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, c As Range
  
  Set Changed = Intersect(Target, Columns("V"), Rows("4:" & Rows.Count))
  If Not Changed Is Nothing Then
    Application.EnableEvents = False
    For Each c In Changed
      c.Offset(, 3).Value = Environ("username")
      c.Offset(, 4).Value = Now
    Next c
    Application.EnableEvents = True
  End If
End Sub


Hi Peter,

i have tested and it works, so thank you for that. i do have one question, can the code be tweaked so that if column V has Active selected can Y,Z be left blank?

cheers
Ross
 
Upvote 0
Try changing the middle part of the code to this
Code:
For Each c In Changed
  Select Case c.Value
    Case "Won", "Lost"
      c.Offset(, 3).Value = Environ("username")
      c.Offset(, 4).Value = Now
    Case Else
      c.Offset(, 3).Resize(, 2).ClearContents
  End Select
Next c
 
Upvote 0
Hi Peter, suppose I have data in column B and I want to timestamp in Column A when data changes on Column B, how can I achieve that?

Thank you for your usual support.
 
Upvote 0

Forum statistics

Threads
1,216,105
Messages
6,128,859
Members
449,472
Latest member
ebc9

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