Aug 17, 2009

How to Add a comment


Following code show how to add and delete a comment on Cell A1

' Add a comment.
Sub addAComment()

Dim rng As Range
Set rng = ActiveSheet.Cells(1, 1)

If rng.Comment Is Nothing Then
rng.addComment
End If

rng.Comment.Text "Last Reviewed on " & Now()

End Sub


' D
elete a comment.
Sub deleteComment()

Dim rng As Range
Set rng = ActiveSheet.Cells(1, 1)

If Not (rng.Comment Is Nothing) Then
rng.Comment.Delete
End If

End Sub

No comments: