15. VBA Tips - Track Changes By Adding A Time Stamp

Nick's picture


Using VBA Events, there's a clever way to add a time stamp when cells change so that you don't need to remember whether you have updated it or not:

  • To do this, we can use the Worksheet_Change Event
  • We can pick up the event of a change in value in a column, and add the date and time in another 

Here's a screen shot of our data in Excel:

track-changes-by-adding-a-time-stamp

So, every time we change a value in the "Number1" column, a time stamp is updated in the "Last Changed" column

Here's the code we need to use in the worksheet module:

track-changes-by-adding-a-time-stamp

Explanation

  1. Worksheet_Change is an event that is fired off when a cell's value is changed
  2. Target in this case means the cell that has been changed
  3. We then check that we're changing data in the 4th column
  4. Then we add the result of the NOW function to the cell in the same row, but in column 3

Download sheet to practise how to Track Changes By Adding A Time Stamp in Excel

Training Video on how to Track Changes By Adding A Time Stamp in Excel:

AttachmentSize
track-changes-by-adding-a-time-stamp.xls34 KB