Class Comment (Excel VBA)

The class Comment represents a cell comment.

The main procedure of class Comment is Delete

Set

To use a Comment class variable it first needs to be instantiated, for example

Dim lngIndex As Long: lngIndex = 
Dim ws As Worksheet: Set ws = 
Dim cmmComment As Comment
Set cmmComment = ws.Comments(Index:=lngIndex)

The following procedures can be used to set variables of type Comment: Next, Previous, Comments.Item, Range.Comment, Range.AddComment and Worksheet.Comments

For Each

Here is an example of processing the Comment items in a collection.

Dim ws As Worksheet: Set ws = 
Dim cmmComment As Comment
For Each cmmComment In ws.Comments
	
Next cmmComment

Methods

This is the main method of the Comment class

Delete - Deletes the object.

Other Methods

Text - Sets comment text.

Properties

Author returns the author of the comment.

For Each c in ActiveSheet.Comments 
 If c.Author = "Jean Selva" Then c.Delete 
Next

Parent returns the parent object for the specified object. Read-only.

Shape returns a Shape object that represents the shape attached to the specified comment.

ActiveSheet.Comments(2).Shape.Select

Visible returns or sets a Boolean value that determines whether the object is visible.

Comments.Count returns a Long value that represents the number of objects in the collection.

Comments.Parent returns the parent object for the specified object. Read-only.