' Comment Object
' Represent cell annotations
1 Subannotation Add ()2 with[A1]3 If. Comment is Nothing Then4. Addcomment.text"123"5. Comment.visible =True 'Annotations Visible6 End If7 End with8 End Sub
Add Comment: Range.AddComment.Text
Delete Comment: range.clearcomments
1 Sub Delete annotations () 2 for each inch Selection 3 If not is Nothing Then 4 rng.clearcomments5EndIf6Next7 End Sub
Here's the point:
1 Subadd annotations in bulk ()2 for eachRnginchRange ("a2:a20")3Rng.clearcomments'Whether or not annotations are deleted first, it will be an error to add comments on the original annotations .4 IfRng >= - ThenRng.AddComment.Text"Excellent"5 Next6 End Sub
1 Subadd annotations to the background map in batches ()2 for eachRnginchSelection3paths = Thisworkbook.path &"\7pic\"& Rng.value &". PNG" 'Match the pictures in the corresponding picture folder according to the name of the selected area4 rng.clearcomments5 rng.addcomment6Rng.Comment.Shape.Height = -7Rng.Comment.Shape.Width = + 'Set Annotation width8 Rng.Comment.Shape.Fill.UserPicture Paths9 NextTen End Sub
Add annotations to the VBA learning notes