DATE/TIME Stamp for "COMMENTS"

cmyeyez

Board Regular
Joined
May 10, 2013
Messages
62
does excel have an auto- date/time stamp that can be placed into the comments?
(similar to how the UserName auto populates in the comment based on who the excel software is registered under)
I would need this to track the date/time a comment was added to a cell.

Many thanks!
 
Thanks for the response Tom.
How do I get the code to run for any cell in the workbook and not just cell $A$1?
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
If by "any cell in the workbook" you really mean workbook and not worksheet, then follow these steps:

Step 1
Delete the code I posted from your worksheet module.

Step 2
Place the following code in your workbook module and see if it accomplishes what you are after. To easily access your workbook module, in Excel version 2003 or before, find the little Excel workbook icon near the upper left corner of your workbook window, usually just to the immediate left of the File menu option. Right-click on that icon, and left-click to select View Code. In Excel versions 2007 or after, from your worksheet press Alt+F11, then press Ctrl+R, find your workbook name in the "Project - VBAProject" left vertical pane, expand the Microsoft Excel Object folder for your workbook, right click on ThisWorkbook and left-click to select View Code. Paste the following procedure into the large white area that is the workbook module, then press Alt+Q to return to the worksheet.

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
With Target
If IsEmpty(Target) Then Exit Sub
Dim strNewText$, strCommentOld$, strCommentNew$
strNewText = .Text
If Not .Comment Is Nothing Then
strCommentOld = .Comment.Text & Chr(10) & Chr(10)
Else
strCommentOld = ""
End If
On Error Resume Next
.Comment.Delete
Err.Clear
.AddComment
.Comment.Visible = False
.Comment.Text Text:=strCommentOld & _
Format(VBA.Now, "MM/DD/YYYY at h:MM AM/PM") & Chr(10) & strNewText
.Comment.Shape.TextFrame.AutoSize = True
End With
End Sub
 
Upvote 0
cmyeyez,
Here is a test sheet with a sub that will do what you want, use it carefully because it has some performance issues, it test every comment in the active sheet, I did not find an event to check for comment changes, so I check them all, the test sheet is here:
https://dl.dropboxusercontent.com/u/23094164/cmyeyez2.xlsm
The code is here:
Code:
Private Sub WorkSheet_SelectionChange(ByVal Target As Range)
Dim mark, cmtt As String
Dim cmt As Comment
mark = " " & "##" & vbNewLine
    For Each cmt In ActiveSheet.Comments
        If Right(cmt.Text, Len(mark)) <> mark Then
            cmtt = cmt.Text
            cmt.Delete
            cmt.Parent.AddComment Text:=cmtt & vbNewLine & Format(Date + Time, "YYYY-MM-DD HH:MM:SS") & mark
        End If
    Next cmt
End Sub
Cheers
Sergio
 
Upvote 0
tom -
with the above code, when I add a comment to cell A1 there is no time stamp.
just my user name (by default) and the actual comment.
 
Upvote 0
Works Great Sergio!
My picky nature is wondering why the "BOLD" font was removed from the default user name in the comment?
 
Upvote 0
the bold is removed when I delete the comment and then I use the method AddComment with old comment plus timestamp plus the mark, I did not find the update comment method sorry
Cheers
Sergio
 
Upvote 0

Forum statistics

Threads
1,223,793
Messages
6,174,635
Members
452,575
Latest member
Fstick546

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top