Comment with date stamp, again



Here's a step-by-step:

1. Copy code below:

Sub CommentDateTimeAdd()
Dim strDate As String
Dim cmt As Comment

strDate = "ddd, mm-dd-yy h:mm AM/PM"
Set cmt = ActiveCell.Comment

Set cmt = ActiveCell.AddComment
cmt.Text Text:=Format(Now, strDate) & Chr(10) _
& "NOTE:"

End Sub

2. Open a new workbook
3. Click on "View Code" from any sheet
4. On the Visual Basic window click "Insert>Module"
5. Paste code into Module1
6. Return to sheet
7. Click "Tools>Customize" and a window pops up
8. Select "Insert" menu at top of page (not in the open window)
9. Select "Comment" from drop-down menu from "Insert"
10 Right click and select "Assign Macro" from drop-down menu
11 Click on "CommentDateTimeAdd" from Macro window>"OK", window closes
12 Click "Close" on the still open "Customize" window

Am I missing anythng?



Gary''s Student

Your code will throw an error if the activecell already has a comment. You
might want to:

1. test for a comment and exit
2 test for a comment and delete it before putting the new one in.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question