Everyday Documents

Home|Articles

Excel Macro: Automated Date & Time Stamp

Use excel macros to automatically datestamp & timestamp rows on user entry.

Oct 3, 2022 - 2 min read

Give your spreadsheets a secret superpower!

What it does

This macro will automatically enter the current date into column 1 and current time into column 2, when a user enters data into column 3. This applies to any row in the spreadsheet, but only if column 1 and column 2 are emtpy for that row.

The macro

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 3 And Cells(Target.Row, 1) = "" And Cells(Target.Row, 2) = "" Then
        Application.EnableEvents = False
        Cells(Target.Row, 1) = Date
        Cells(Target.Row, 2) = Time
        Application.EnableEvents = True
    End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub

Access the Visual Basic editor using Alt+F11.

How to use it

  • Step 1: Open a new spreadsheet or download our Correspondence Register template.
  • Step 2: Press 'Alt+F11' to access the Visual Basic Editor.
  • Step 3: Double click on 'Sheet1' and paste in the above code.
  • Step 4: Save the file as an 'Excel Macro-Enabled Workbook'. The automation will now be active.

Open the Visual Basic editor and paste in the code

Free download

The correspondence register template is available as a free download from our website. Click the link below to open the download page.

Download template

Latest Articles

Show more articles