Formatting text in a Comment

G

Greg0069

I am working on a macro that creates comments and populate them wit
list of values and I would like to put the first line in each comment
box in bold or underlined because it is the title. How can I do that?

Thanks
Greg from Pari
 
D

Dave Peterson

If you're creating the first line by adding a VbLF (or chr(10)) in your code,
you could use something like:

Option Explicit
Sub testme01()

Dim myComment As Comment
Dim LFPos As Long

For Each myComment In ActiveSheet.Comments
With myComment
LFPos = InStr(1, .Text, vbLf)
If LFPos > 0 Then
With .Shape.TextFrame.Characters(Start:=1, Length:=LFPos).Font
.Bold = True
.Underline = True
End With
End If
End With
Next myComment

End Sub
 
Top