vba add timestamp after macro execution in Excel

Q157. In Excel, how can I add a Timestamp after macro execution?

To do it in Excel, here is the answer:

  1. Option Explicit
  2. Sub AddTimeStamp()
  3. ActiveSheet.Range("A2") = "Last Updated On " & Format(Now, "dd-mmm-yyyy, hh:mm")
  4. End Sub


a) Line 3 gets the system time and updates cell A2 with the same in the specified format.

Result after Macro execution:

excel vba add timestamp after macro execution


You can find similar Excel Questions and Answer hereunder

1) How can I turn off Alerts using VBA?

2) I frequently use a Macro - is there a way to quickly access the Macro using a Keyboard Shortcut?

3) How can I set FreezePanes in a certain range using VBA?

4) How can I export a WorkSheet as a PDF using VBA?

5) Vba code to password protect workbook in Excel

6) How to concatenate strings in vba in Excel

7) How can I list all files in a folder using VBA?

8) How can I shade alternate rows in color using VBA to make it easier to read voluminous data running into hundreds of rows?

9) Converting numbers stored as text to numbers via macro in Excel

10) How to disable ability to insert Rows and Columns in Excel (using VBA)?

11) How can I change the Marker size and Marker line color for all the series in a chart?

12) How can I get users to select a file for processing using my macro?

13) How can I add a Prefix to a set of numbers in a range?

14) How do I add a shape using VBA?

15) How can I set non-contiguous print area using VBA?