Comment Object and the Comments Collection Example

This example removes the user name added by Excel at the start of the comment and formats the comment to make it more readable:

Sub FormatComments()

Dim oComment As Comment, i As Integer 'Loop through all the comments in the sheet For Each oComment In ActiveSheet.Comments 'Using the text of the comment( With oComment.Shape.TextFrame.Characters

'Find and remove the user name inserted by Excel i = InStr(1, .Text, ":" & vbLf) If i > 0 Then

'Increase the font size With .Font

.Name = "Arial" .Size = 10 .Bold = False End With End With

'Make the text frame auto-fit oComment.Shape.TextFrame.AutoSize = True Next End Sub

0 0

Post a comment