Formatting a comment using code

J

Jock

Hi,
the following is part of some code which adds a comment box with a date:

Format(Target.Value + 28, "dd mmm yy")

How can I make the date bold as well?

Thanks
 
G

Gary''s Student

Sub Formatter()
Dim s As String
Set target = ActiveCell
s = Format(target.Value + 28, "dd mmm yy")
Set cmt = target.Offset(0, 1).AddComment(Text:=s)
With cmt.Shape.TextFrame.Characters(1, 9)
.Font.Bold = True
End With
End Sub

Note:

I put a date in A1 and selected it, comment seems good.
 
J

Jock

Hi Gary"s Student

Rather than re-write the code from scratch, I was hoping to modify what I
already have:

'adds a comment box to cells in column N if a "Certificate of Service" (I)
date is entered
On Error Resume Next
If Not Intersect(Target, Me.Range("I4:I30")) Is Nothing Then
With Target
If .Value <> "" Then
Application.EnableEvents = False
Target.Offset(0, 5).AddComment.Text Text:="Defence due: " &
Format(Target.Value + 14, "dd mmm yy")
'On Error GoTo 0
Application.EnableEvents = True
End If
End With
End If

Because there's text as well as dates in the comments, I wanted to make the
dates stand out. Also, depending on what happens elsewhere on the sheet,
these comments can be amended with new dates by code. Again, I'd llike the
new dates in bold and (hey, let's go mad here) and the original text
formatted as strikethrough.

Is this do-able?
Cheers,
 
G

Gary''s Student

Indeed.....

Just made adjustments in the .Characters(1, 9) line to re-format only the
characters your desire!
 

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

Similar Threads


Top