automatic comment box size change

mikeha_99

Board Regular
Joined
Oct 30, 2006
Messages
108
Hello,
Thanks to Mr. Excel I have a functioning macro that puts a cell comment in based on the contents of certain cells. Plus, it adjusts the size of the font up to 16. This is working well, but I need one more tweak.

I would like it if the comment boxes were either larger at a preset size (height and width) or if they could automatically be sized based on the amount of text. Below is my current code:

Code:
Sub addcmt()
Dim LR As Long
LR = Range("K" & Rows.Count).End(xlUp).Row
For i = 1 To LR
   Range("C" & i).NoteText Text:=Range("K" & i).Value
Next i
Dim c As Range, fSize As String
fSize = 16
If fSize = "" Or Not IsNumeric(Val(fSize)) Or Val(fSize) < 1 Then
    Exit Sub
Else
    fSize = Val(fSize)
End If
On Error Resume Next
For Each c In ActiveSheet.UsedRange.SpecialCells(xlCellTypeComments)
    If c Is Nothing Then
        MsgBox "Can't find any cells with comments on the ActiveSheet"
        Exit Sub
    End If
    With c.Comment.Shape.TextFrame.Characters
        .Font.Size = fSize
    End With
Next c
End Sub

Any and all help is greatly appreciated.

Mike
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Try

Code:
    With c.Comment.Shape.TextFrame
        .Characters.Font.Size = fSize
        .AutoSize = True
    End With
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,904
Members
452,948
Latest member
Dupuhini

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