Excel VBA macrosHack 33
    columns
    data collection
    database
    date stamp
    timestamp
    worksheet change
    worksheet macros

    Auto-Insert a Timestamp When a Cell is Updated in Excel (VBA)

    Excel Hack #33

    13 views
    1 min read
    2018-10-18
    Auto-Insert a Timestamp When a Cell is Updated in Excel (VBA)

    You may be working on databases or tables in Excel that contain changing data which needs to be timestamped. You could manually enter the date or time every time you work (or use the keyboard shortcut...

    You may be working on databases or tables in Excel that contain changing data which needs to be timestamped. You could manually enter the date or time every time you work (or use the keyboard shortcut Ctrl + : which brings in the current date and time). However, if you want to automate this task, you could use the following macro.
     
    This code works within the target worksheet and gets activated when a change is detected in any cells in Column C (the 3rd column). It responds to the change by entering the current date and time in the column next to Column C - the 4th column.
     
     
    Private Sub Worksheet_Change(ByVal Target As Range)
     
    If Target.Column = 3 Then
     Application.EnableEvents = False
     Cells(Target.Row,4).Value = Date + Time
     Application.EnableEvents = True
    End If
     
    End Sub
     
     
    Screen Shot 2018-10-18 at 12.29.06 PM
     
    Adjust the column numbers as appropriate for you. If you wanted just the date and not the time, remove “+ Time” at the end of the third line of the code.
     
    Remember to place the code within the focus worksheet (Sheet1) coding area, and not in ThisWorkbook or a Module.
     
    Screen Shot 2018-10-18 at 12.29.28 PM

    Frequently Asked Questions