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 01, 2018Silver Contributor
Hi Joseph,
This is possible, but you definitely need to a VBA code to do it!
Let's say the five cells you want to target are from cell A1 to E1, so please hover the Mouse over the Worksheet tab, right-click, and select View Code.
Then copy and paste this code into the worksheet code module:
Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Or _
Not Intersect(Target, Range("B1")) Is Nothing Or _
Not Intersect(Target, Range("C1")) Is Nothing Or _
Not Intersect(Target, Range("D1")) Is Nothing Or _
Not Intersect(Target, Range("E1")) Is Nothing Then
Target.Offset(1, 0) = Now
End If
End Sub
After that, save the workbook as .xlsm file extension to keep the code saved in it.
If you want to apply it to different cells, simply, you can change the cell ranges in the code and their order in the code does not matter!.
Hope that helps