ExcelBanter

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

Keyrookie

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 "InsertModule"
5. Paste code into Module1
6. Return to sheet
7. Click "ToolsCustomize" 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?

K

Gary''s Student

Comment with date stamp, again
 
Your code will throw an error if the activecell already has a comment. You
might want to:

1. test for a comment and exit
or
2 test for a comment and delete it before putting the new one in.
--
Gary''s Student - gsnu200909


"Keyrookie" wrote:


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 "InsertModule"
5. Paste code into Module1
6. Return to sheet
7. Click "ToolsCustomize" 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?

K




--
Keyrookie
.



All times are GMT +1. The time now is 11:47 PM.

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