Cell Comment Box Cutting Off Text Using Shape.Width

mmnunn

New Member
Joined
Mar 1, 2010
Messages
17
hello, i am having trouble getting my comment box to autosize and then shrink to a square showing the entire set of text. in the below code if i delete the "shape.width = 430" portion i get an autosize that works correctly to show all text but it stretches the box to be thin and very long. using "shape.width = 430" shrinks the box to be entirely visible on the page but it is cutting off text at the bottom that i want to see. any advice is greatly appreciated.

Code:
Public Sub add_comment_box()
For i = 2 To finalrow
    Connect = Cells(i, 2).Value & "_" & DealName
    iVal = Application.WorksheetFunction.CountIf(Range("O2:O100"), Connect)
    If iVal > 0 Then
        Comments = Cells(14, 6).Value
        Cells(i, 4).Select
        With Selection
            .AddComment Comments
            .Comment.Shape.TextFrame.Characters.Font.Size = 12
   ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
            ' this will autofit the comment box to be just the size of the text inside.
            .Comment.Shape.TextFrame.AutoSize = True
            .Comment.Shape.Width = 430
   ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        End With
        Else: GoTo skip 'next i
    End If
    Cells(14, 6).ClearContents
    
skip:
Next i
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,215,321
Messages
6,124,239
Members
449,149
Latest member
mwdbActuary

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