ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formatting a comment by code (https://www.excelbanter.com/excel-programming/429865-formatting-comment-code.html)

Jock

Formatting a comment by code
 
How can I apply bold formatting to the date part of the following code?
Target.Offset(0, 2).AddComment UserName() & " - AoS due by: " &
Format(strTemp, "dd/mm/yy")
--
Traa Dy Liooar

Jock

Dave Peterson

Formatting a comment by code
 
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim strTemp As Date

If Target.Cells.Count 1 Then
Exit Sub
End If

If Intersect(Target, Me.Range("A:A")) Is Nothing Then
Exit Sub
End If

strTemp = Date

With Target.Offset(0, 2)
If .Comment Is Nothing Then
'do nothing
Else
.Comment.Delete
End If

.AddComment Application.UserName & " - AoS due by: " _
& Format(strTemp, "dd/mm/yy")

.Comment.Shape.TextFrame _
.Characters(Len(.Comment.Text) - 7, 8).Font.Bold = True

End With

End Sub
Jock wrote:

How can I apply bold formatting to the date part of the following code?
Target.Offset(0, 2).AddComment UserName() & " - AoS due by: " &
Format(strTemp, "dd/mm/yy")
--
Traa Dy Liooar

Jock


--

Dave Peterson

Jock

Formatting a comment by code
 
Hi Dave,
Thanks for your code.
As the snippet of code I placed in my thread is only a very small part of a
bigger picture, I can't replace mine with your example.
I have tried to add the line
..Comment.Shape.TextFame.... in various guises to my code however nothing
goes bold in the comment.
Thanks for trying though.
--
Traa Dy Liooar

Jock


"Dave Peterson" wrote:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim strTemp As Date

If Target.Cells.Count 1 Then
Exit Sub
End If

If Intersect(Target, Me.Range("A:A")) Is Nothing Then
Exit Sub
End If

strTemp = Date

With Target.Offset(0, 2)
If .Comment Is Nothing Then
'do nothing
Else
.Comment.Delete
End If

.AddComment Application.UserName & " - AoS due by: " _
& Format(strTemp, "dd/mm/yy")

.Comment.Shape.TextFrame _
.Characters(Len(.Comment.Text) - 7, 8).Font.Bold = True

End With

End Sub
Jock wrote:

How can I apply bold formatting to the date part of the following code?
Target.Offset(0, 2).AddComment UserName() & " - AoS due by: " &
Format(strTemp, "dd/mm/yy")
--
Traa Dy Liooar

Jock


--

Dave Peterson


Patrick Molloy

Formatting a comment by code
 
all you needed to do was add a line

below this:
Target.Offset(0, 2).AddComment UserName() & " - AoS due by: " &
Format(strTemp, "dd/mm/yy")
add Dave Peterson's code:
target.Offset(0, 2).Comment.Shape.TextFrame _
.Characters(Len(target.Offset(0, 2).Comment.Text) - 7,
8).Font.Bold = True


"Jock" wrote in message
...
Hi Dave,
Thanks for your code.
As the snippet of code I placed in my thread is only a very small part of
a
bigger picture, I can't replace mine with your example.
I have tried to add the line
.Comment.Shape.TextFame.... in various guises to my code however nothing
goes bold in the comment.
Thanks for trying though.
--
Traa Dy Liooar

Jock


"Dave Peterson" wrote:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim strTemp As Date

If Target.Cells.Count 1 Then
Exit Sub
End If

If Intersect(Target, Me.Range("A:A")) Is Nothing Then
Exit Sub
End If

strTemp = Date

With Target.Offset(0, 2)
If .Comment Is Nothing Then
'do nothing
Else
.Comment.Delete
End If

.AddComment Application.UserName & " - AoS due by: " _
& Format(strTemp, "dd/mm/yy")

.Comment.Shape.TextFrame _
.Characters(Len(.Comment.Text) - 7, 8).Font.Bold = True

End With

End Sub
Jock wrote:

How can I apply bold formatting to the date part of the following code?
Target.Offset(0, 2).AddComment UserName() & " - AoS due by: " &
Format(strTemp, "dd/mm/yy")
--
Traa Dy Liooar

Jock


--

Dave Peterson


Jock

Formatting a comment by code
 
Thanks to Patrick and Dave
--
Traa Dy Liooar

Jock


"Patrick Molloy" wrote:

all you needed to do was add a line

below this:
Target.Offset(0, 2).AddComment UserName() & " - AoS due by: " &
Format(strTemp, "dd/mm/yy")
add Dave Peterson's code:
target.Offset(0, 2).Comment.Shape.TextFrame _
.Characters(Len(target.Offset(0, 2).Comment.Text) - 7,
8).Font.Bold = True


"Jock" wrote in message
...
Hi Dave,
Thanks for your code.
As the snippet of code I placed in my thread is only a very small part of
a
bigger picture, I can't replace mine with your example.
I have tried to add the line
.Comment.Shape.TextFame.... in various guises to my code however nothing
goes bold in the comment.
Thanks for trying though.
--
Traa Dy Liooar

Jock


"Dave Peterson" wrote:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim strTemp As Date

If Target.Cells.Count 1 Then
Exit Sub
End If

If Intersect(Target, Me.Range("A:A")) Is Nothing Then
Exit Sub
End If

strTemp = Date

With Target.Offset(0, 2)
If .Comment Is Nothing Then
'do nothing
Else
.Comment.Delete
End If

.AddComment Application.UserName & " - AoS due by: " _
& Format(strTemp, "dd/mm/yy")

.Comment.Shape.TextFrame _
.Characters(Len(.Comment.Text) - 7, 8).Font.Bold = True

End With

End Sub
Jock wrote:

How can I apply bold formatting to the date part of the following code?
Target.Offset(0, 2).AddComment UserName() & " - AoS due by: " &
Format(strTemp, "dd/mm/yy")
--
Traa Dy Liooar

Jock

--

Dave Peterson



Patrick Molloy

Formatting a comment by code
 
"Traa Dy Liooar " ??

:)

"Jock" wrote in message
...
Thanks to Patrick and Dave
--
Traa Dy Liooar

Jock


"Patrick Molloy" wrote:

all you needed to do was add a line

below this:
Target.Offset(0, 2).AddComment UserName() & " - AoS due by: " &
Format(strTemp, "dd/mm/yy")
add Dave Peterson's code:
target.Offset(0, 2).Comment.Shape.TextFrame _
.Characters(Len(target.Offset(0, 2).Comment.Text) - 7,
8).Font.Bold = True


"Jock" wrote in message
...
Hi Dave,
Thanks for your code.
As the snippet of code I placed in my thread is only a very small part
of
a
bigger picture, I can't replace mine with your example.
I have tried to add the line
.Comment.Shape.TextFame.... in various guises to my code however
nothing
goes bold in the comment.
Thanks for trying though.
--
Traa Dy Liooar

Jock


"Dave Peterson" wrote:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim strTemp As Date

If Target.Cells.Count 1 Then
Exit Sub
End If

If Intersect(Target, Me.Range("A:A")) Is Nothing Then
Exit Sub
End If

strTemp = Date

With Target.Offset(0, 2)
If .Comment Is Nothing Then
'do nothing
Else
.Comment.Delete
End If

.AddComment Application.UserName & " - AoS due by: " _
& Format(strTemp, "dd/mm/yy")

.Comment.Shape.TextFrame _
.Characters(Len(.Comment.Text) - 7, 8).Font.Bold = True

End With

End Sub
Jock wrote:

How can I apply bold formatting to the date part of the following
code?
Target.Offset(0, 2).AddComment UserName() & " - AoS due by: " &
Format(strTemp, "dd/mm/yy")
--
Traa Dy Liooar

Jock

--

Dave Peterson




All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com