How to Auto Add Date and Time to Comment in Excel?


When we added the comments to the cells in Excel, you may have noticed that the comment will only contain the name of the user, but we can also customise the comment to add the date and time to the spreadsheet. We can use the process mentioned below to automatically add date and time to comments in Excel.

Read this tutorial to understand how you can automatically add date and time to comments in Excel by following a simple process.

Auto Add Date and Time to Comment in Excel

Here we will first insert a comment and then insert a VBA module to complete our task. Let's take a look at a simple procedure for adding date and time to comments in Excel. We will be using the help of the VBA application to complete our requirement, as it can’t be completed without the VBA code.

Step 1

Let's consider a new Excel sheet, then type your data and insert your comment by clicking right on "Comment" to insert the comment and entering your comment. Our comment will be displayed similarly to the comment shown in the below image.

To add a date and time, click on the cell, then right-click on the sheet name and select view code to open the VB application, then click on insert and select module, and finally type the programme into the text box as shown in the image below. 

Program

Sub DatedComment()
   'Update Nirmal
   Dim pComment As Comment
   Dim WorkRng As Range
   Set WorkRng = Application.ActiveCell
   Set pComment = WorkRng.AddComment(Application.UserName & ":" & vbLf & Now & vbLf)
   pComment.Shape.TextFrame.Characters(1, VBA.Len(Application.UserName) + 1).Font.Bold = True
End Sub

Step 2

Now save the file as a macro-enabled text file and click on "run" to successfully complete our process, and our comment will have a time stamp added to it as shown in the below image.

Conclusion

In this tutorial, we used a simple example to demonstrate how we can automatically add date and time to the comments in Excel to highlight particular sets of data.

Updated on: 03-Jan-2023

629 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements