ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Comment with date stamp (https://www.excelbanter.com/excel-worksheet-functions/250561-comment-date-stamp.html)

Keyrookie

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


All times are GMT +1. The time now is 08:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com