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
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Watch MrExcel Video

Forum statistics

Threads
1,122,521
Messages
5,596,652
Members
414,083
Latest member
Mrsash

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