Formatting text in a Comment

  • Thread starter Thread starter Greg0069
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top