comment text property.

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
hi gurus!!!

Is there a way to change the font size and style of a comment of a certain cell?
I mean is it possible to have the sizes of comments varies in one worksheet?

thanks!!!
 
PA HS Teacher said:
What if you ran the highlight code on some sort of worksheet event?
Like when a certain cell recalculated? I did not know the possibillity existed. How is that done?
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I don't know if its possible to have an event triggered only if a particular cell calculates. But if the sheet calculates you could run something like the following.

Private Sub Worksheet_Calculate()
' Call Highlight Routine
End Sub

Though this could get slow, if you have many cells to run this routine for each time a change is made.


To run the routine whenever a certain cell is selected you could do the following.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = Range("A1").Address Then
' Call Highlight Routine Here
End Sub

I know you can have a worksheet change event.
I don't think (but I don't know) that a recalculation of a cell constitutes a change for that cell, and I don't have time to play around with it right now.'

In any case, play around with events.
 
Upvote 0
Based on your example, this will format the word "Excel" in bold red font if it is found in the text of any comments on the active sheet. You can modify the term from "Excel" to something else in the code by changing this line
TextToFormat = "Excel"
to some other term.



Sub Test1()
Application.ScreenUpdating = False

Dim cell As Range, i As Integer
Dim cText As String, TextToFormat As String
TextToFormat = "Excel"

On Error Resume Next

For Each cell In Cells.SpecialCells(1)
cText = cell.Comment.Text

If InStr(cText, TextToFormat) > 0 Then
With cell.Comment.Shape.TextFrame
.Characters.Font.Bold = False
.Characters.Font.ColorIndex = 1
For i = 1 To Len(cText) - Len(TextToFormat) Step 1
If Mid(cText, i, Len(TextToFormat)) = TextToFormat Then
.Characters(i, Len(TextToFormat)).Font.Bold = True
.Characters(i, Len(TextToFormat)).Font.ColorIndex = 3
End If
Next i
End With

If Right(cText, Len(TextToFormat)) = TextToFormat Then
With cell.Comment.Shape.TextFrame.Characters((Len(cText) - Len(TextToFormat)), Len(cText)).Font
.ColorIndex = 3
.Bold = True
End With
End If

End If
Next cell

Application.ScreenUpdating = True

If Err.Number <> 0 Then
Err.Clear
Application.ScreenUpdating = True
MsgBox "No cells on this sheet contain comments.", 48, "Nothing to format."
End If

End Sub


This works really well for me too. But how do I modify if I want to bold the work VBA as well? In this case, just Excel and VBA should be bolded and all else is unbolded.

Thanks!!!
 
Upvote 0

Forum statistics

Threads
1,215,409
Messages
6,124,730
Members
449,185
Latest member
ekrause77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top