Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formatting a comment using code
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 -- Traa Dy Liooar Jock |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formatting a comment using code
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. -- Gary''s Student - gsnu200852 "Jock" wrote: 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 -- Traa Dy Liooar Jock |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formatting a comment using code
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, -- Traa Dy Liooar Jock "Gary''s Student" wrote: 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. -- Gary''s Student - gsnu200852 "Jock" wrote: 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 -- Traa Dy Liooar Jock |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formatting a comment using code
Indeed.....
Just made adjustments in the .Characters(1, 9) line to re-format only the characters your desire! -- Gary''s Student - gsnu200852 "Jock" wrote: 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, -- Traa Dy Liooar Jock "Gary''s Student" wrote: 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. -- Gary''s Student - gsnu200852 "Jock" wrote: 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 -- Traa Dy Liooar Jock |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel comment formatting | Excel Discussion (Misc queries) | |||
Preserving Comment Box Formatting | Excel Programming | |||
Code to add comment box | Excel Programming | |||
Formatting certain text within a comment | Excel Programming | |||
VB Code to size the comment box | Excel Programming |