Macro to insert a comment in a selection of cells + change the font size to 14

edge37

Board Regular
Joined
Sep 1, 2016
Messages
102
Office Version
  1. 365
Platform
  1. Windows
Good day! Can you please help me in the following? I need to have a macro where I can select one or many specific cells in a worksheet to insert a comment (like: "approved" as an example), and also, in the same macro, I would like the comment to have a font size of 14.

Thank you for your great work.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try this:

VBA Code:
Sub add_comments()
  Dim c As Range
  
  For Each c In Selection
    'If the cell already has a comment'
    On Error Resume Next: c.AddComment: On Error GoTo 0
    c.Comment.Visible = True
    
    'text in comment
    c.Comment.Text Text:="approved"
    
    'font style
    With c.Comment.Shape.TextFrame.Characters.Font
      .Size = 14
      .Name = "Arial"
      .Bold = False
    End With
    
    'Adjust the size of the comment box
    c.Comment.Shape.TextFrame.AutoSize = True
    
    'comment box property
    c.Comment.Shape.Placement = xlMoveAndSize
  Next
End Sub

Note: I added comments in each line of the macro, if any line does not work for you, you can simply remove it from the macro.


----- --
Let me know the result and I'll get back to you as soon as I can.
Sincerely
Dante Amor
----- --
 
Upvote 0
Thank you, it is almost what I need, tyhe only thing is that the comments just sits there all at once showing all the time. I would need it to work just as normal (when hovering the cell the comments show up). Check the pic. Can you help me on that? Thanks again
 

Attachments

  • Screenshot_1w.jpg
    Screenshot_1w.jpg
    28.3 KB · Views: 3
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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