Forum Discussion
Joseph Huisman
Oct 01, 2018Copper Contributor
Automatically adding the date/time to a cell when another cell is updated
I am trying to create a spreadsheet where when a specific cell is updated in anyway, the date/time stamp automatically updates in the cell right beneath the cell that was updated. I only need to have...
Haytham Amairah
Oct 03, 2018Silver Contributor
Hi,
In this case, you should inject the Sheet2 with the same code but with some changes to move the time stamp to the right place in Sheet1!
Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
Sheet1.Range("A2") = Now
End If
End Sub
The above example for the Cell A1 in Sheet1 which has a formula referred to cell A1 in Sheet2 (=Sheet2!A1), and you need to put this code in the Sheet2 code module NOT in Sheet1.
If you have more than one cell referred to Sheet2 such as cell A1 and B1 in Sheet1, you have to duplicate the IF statement in the same code of Sheet2 to check each one separately:
Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
Sheet1.Range("A2") = Now
End If
If Not Intersect(Target, Range("B1")) Is Nothing Then
Sheet1.Range("B2") = Now
End If
End Sub
the_goddess
Sep 13, 2022Copper Contributor
Hi Haytham Amairah,
I am using this vba snippet on a shared worksheet that I use with my helpdesk team. If I type information into a cell, the date appears. If one of my teammates who shares the document, types in that cell, the date field appears blank. How can I fix this?
I am using this vba snippet on a shared worksheet that I use with my helpdesk team. If I type information into a cell, the date appears. If one of my teammates who shares the document, types in that cell, the date field appears blank. How can I fix this?