1

I am trying to figure out a way to add the date and time to a cell when another cell is changed. For example I change sth in row 5, then C5 shall save the date and time when it was changed.

I found several entries to change colors on cells values etc, but was not able to find a solution for this problem yet.

Help is much appreciated. Thanks in advance!

yfro
  • 47
  • 9
  • 1
    you should use a macro for this. Look at this post : http://stackoverflow.com/questions/15337008/excel-vba-run-macro-automatically-whenever-a-cell-is-changed – Fabich Apr 29 '16 at 09:13
  • i did not expect that to be possible in vba. thanks! – yfro Apr 29 '16 at 10:01

1 Answers1

1

So open the VBA editor and access the ThisWorkbook object.

Then with the drop-downs above the code window select 'Workbook' from the left hand one, and 'SheetChange' from the right hand one.

It should insert some code. Inside the Sub (before the End Sub code) - Add the following code:

Cells(Target.Row, 3).Value = Date + Time

The whole code in ThisWorkbook object;

Private Sub Workbook_SheetChange(ByVal Sh as Object, ByVal As Range)

    Cells(Target.Row, 3).Value = Date + Time

End Sub

NOTE: This will operate across ALL sheets. If you want to lock this down to specific sheets, insert the code into the Sheet object instead of the ThisWorkbook object, and remove the ByVal Sh as Object, from the arguments

Chris S
  • 81
  • 4