Formatting Cell Comments from VBA

Herve

Board Regular
Joined
May 6, 2003
Messages
68
I am filling the comments for my cells from VBA.

Is there a way to format the text of the comments, i.e., bold, different point size, etc.? (I have tried to record a macro, but that information is not recorded...)

Also, is there a way to get rid of the little red triangle (while keeping the comment poping up when the cursor is over the cell)?

Thanks for any help on this.

Hervé
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
my comment has the following text
"This comment is Arial 12; see Sub FormatComments. It also removes the default name and it will autosize the comment."

The sub follows
Sub FormatComments()
Dim oComment As Comment, i As Integer
For Each oComment In ActiveSheet.Comments
With oComment.Shape.TextFrame.Characters
i = InStr(1, .Text, ":" & vbLf)
If i > 0 Then
.Text = Mid(.Text, i + 2)
End If

With .Font
.Name = "Arial"
.Size = 12
.Bold = True
End With
End With
oComment.Shape.TextFrame.AutoSize = True
Next

End Sub


2. red indicator

I did not test the following line

You could possibly use:
Application.DisplayCommentIndicator = xlNoIndicator


Please advise if the above helps.
 
Upvote 0
Dave,

Thanks a lot for your input. The formatting works beautifully.

Unfortunally, "falsing" the DisplayCommentIndicator also turns off the auto-opening of the comment when the cursor goes over the cell. You then have to right-click to display the comment from the menu.

I have asked for a perfect understanding of the Objects thinggy for Father Day. Will see...

Thanks again and have a great week-end.
 
Upvote 0
Trying to use this code to increase font size in comments - one question:

This file is routinely shared among several users, and our comments are automatically tagged with our system user names. This code seems to scrub those names out. Any suggestions for retaining them?

Thanks
alriemer
 
Upvote 0
Just delete the lines that do not relate to formatting.

It is your choice to leave the name information ( Excel's default).
 
Upvote 0
Cool, got it. Thanks much. Used on a sheet that is formatted with 16 pt font but viewed at 50% to reduce area occupied by borders and grouping.
alriemer
 
Upvote 0
Dave,

I now want to change the format of a single cell, not the whole page as we do with the code above (I just want to reformat one cell in order to speed up processing time).

Is there a way to do that?

Thanks!
 
Upvote 0
Did you try to change the format?

While in Comment, right-clcik and access the format comment dialogue box.
 
Upvote 0
Experiment with something like


Sub FormatComments2()

Range("F2").Comment.Shape.TextFrame.Characters.Font.Size = 12


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,047
Messages
6,122,858
Members
449,096
Latest member
Erald

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