Name
comment.Text([Text], [Start], [Overwrite])
Synopsis
Gets or sets the text displayed in a comment.
|
Argument |
Settings |
|---|---|
|
|
The text to display in the comment. |
|
|
The character position at which to insert the text. If omitted, any existing comment is overwritten. |
|
|
True replaces the existing comment; False appends. Default is False. |
The following code creates four new comments on the active worksheet:
Sub CreateComments( )
Dim cel As Range
For Each cel In [a1:b2]
cel.AddComment "Comment for " & cel.Address
Next
End SubThe Text method also returns the text of the comment. For example, the following code lists all of the comments on the active sheet:
Sub ShowComments( )
Dim cmt As Comment
Debug.Print "Author", "Text"
For Each cmt In ActiveSheet.Comments
Debug.Print cmt.Author, cmt.Text
Next
End SubBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access