View Single Post
  #1   Report Post  
Keyrookie Keyrookie is offline
Member
 
Posts: 84
Default Comment with date stamp

Hello all,

I copied these macros from the "Contextures" site but I would like some help. I've already run the this macro:

Sub CommentNote()
Application.UserName = "Note"
End Sub


...but I would like to also have a automatic time stamp in the comment as well. I can run the following macro but the comment only shows the time, not the above "Note" and you have to run the macro for the time to show.


To insert a comment with the current date and time, or append the current date and time to an existing comment, use the following macro:

Sub CommentDateTimeAdd()
'adds comment with date and time,
' positions cursor at end of comment text
'www.contextures.com\xlcomments03.html

Dim strDate As String
Dim cmt As Comment

strDate = "dd-mmm-yy hh:mm:ss"
Set cmt = ActiveCell.Comment

If cmt Is Nothing Then
Set cmt = ActiveCell.AddComment
cmt.text text:=Format(Now, strDate) & Chr(10)
Else
cmt.text text:=cmt.text & Chr(10) _
& Format(Now, strDate) & Chr(10)
End If

With cmt.Shape.TextFrame
.Characters.Font.Bold = False
End With

SendKeys "%ie~"

End Sub



I'm wanting to have comments look like this:

12-8-09 10:30 AM (whatever the date & time was upon "Insert Comment")
Note:



Thanks in advance,

K