Formatting a comment using code

  • Thread starter Thread starter Jock
  • Start date Start date
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
 
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.
 
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,
 
Indeed.....

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