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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,956
Messages
5,856,507
Members
431,819
Latest member
hellosunshine

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
Top