Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 440
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel comment formatting mleinok Excel Discussion (Misc queries) 3 June 27th 07 07:40 PM
Preserving Comment Box Formatting KC VBA Qns Excel Programming 3 August 24th 06 12:09 PM
Code to add comment box chris46521[_9_] Excel Programming 2 July 28th 06 03:22 PM
Formatting certain text within a comment pikapika13[_15_] Excel Programming 1 July 13th 06 03:45 PM
VB Code to size the comment box SUNIL PATEL Excel Programming 1 July 1st 04 09:26 PM


All times are GMT +1. The time now is 07:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"