Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I see that when I add new a comment to a cell, Excel auto insert my username into it. So I wonder whether or not we can configure the way Excel add header to my comment.
Actually, I need Excel to auto-insert date when I insert a new comment. Can I do it? If yes, can you give some guide to do it!
Thanks! username
add new comment


FYI, I'm trying with some pieces of VBA code, but still can't get anything helpful! Maybe next weekend... humph

share|improve this question
1  
Do you want it for one specific file or Excel in general? –  Siim K Nov 11 '11 at 9:58
    
@SiimK I want it for all Excel files. –  LongTTH Nov 14 '11 at 3:20
    
you should accept answers from your previous questions. --> see meta.stackexchange.com/questions/5234/… –  JMax Nov 16 '11 at 9:26

1 Answer 1

up vote 1 down vote accepted

There isn't any easy way to do this. If it is a one-time thing, you can go into Excel Options and add the date to your user name. You would have to remember to undo the change when done.

Other than that you would have to write some code. Unfortunately, Excel doesn't register an event when you create or edit a comment so you can't edit a comment as it is being created. The best you can do is write a routine to handle the adding of comments. You would then need to always use the macro for adding comments.

Here is a quick example:

Sub AddNewComment()
   Dim sComment As String, rng As Range

   If TypeName(Selection) = "Range" Then
      Set rng = Selection

      sComment = InputBox("Enter your comment.", "Add New Comment")
      If Len(sComment) > 0 Then
         ' append date and username to comment
         sComment = Format(Date, "m/d/yy") & " " & Application.UserName & ":" & vbLf & sComment
         If rng.Comment Is Nothing Then
            rng.AddComment sComment
         Else
            ' append new comment to existing comment
            rng.Comment.Text vbLf & sComment, Len(rng.Comment.Text) + 1, False
         End If

      End If

      Set rng = Nothing
   End If

End Sub

Note: All text will be plain. You can't set part of your text (UserName) as bold with the .Text function.

share|improve this answer

protected by Troggy Aug 6 '13 at 6:25

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.