Skip to main content

How to auto-size comment box to fit its content in Excel?

When you insert comments to cells, the size of the comment box is the default. If you enter a lot of contents into it, some of the content will not be visible directly. Is it possible to fit the size of the comment box to its content automatically?

Auto-size comment box to fit its content in a worksheet
Auto-size comment box to fit its content in a range of cells
Easily auto-size comment box to fit its content in active sheet or all sheet with an amazing tool


Auto-size comment box to fit its content in a worksheet

In Excel, you can drag the comment box to your need size manually one by one, but if there are numerous comment boxes need to be resized, this way will be tedious and time-consuming. In this case, you can apply the following VBA code.

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following macro in the Module window.

VBA code: Auto-size comment boxes in a worksheet

Sub FitComments()
'Updateby20140325
Dim xComment As Comment
For Each xComment In Application.ActiveSheet.Comments
    xComment.Shape.TextFrame.AutoSize = True
Next
End Sub

3. Then press F5 key to run this code, and all of the comment boxes in the active worksheet have been resized to fit their contents as following screenshot shown:

doc autosize comment1

Tip: This code only work in the current worksheet, and it cannot automatically resize the new comment boxes you add.


One click to quickly fit the size of the comment box to its content automatically in Excel:

The Autofit Comment utility of Kutools for Excel can help to quickly fit the size of the comment box to its content automatically in a worksheet as the below demo shown. Download and try it now! (30-day free trail)


Auto-size comment box to fit its content in a range of cells

If you just need to auto-size a range of cell comment boxes, you can use the following VBA code.

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following macro in the Module window.

VBA code: Auto-size comment boxes in a range of cells

Sub Fitrangecomments()
'Updateby20140325
Dim rng As Range
Dim WorkRng As Range
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each rng In WorkRng
    If Not rng.Comment Is Nothing Then
        rng.Comment.Shape.TextFrame.AutoSize = True
    End If
Next
End Sub

3. Then press F5 key to execute this code, and a prompt box will appear to remind you selecting a range of cells that you want to resize the comment boxes, see screenshot:

doc-resize-comment-box3

4. And then click OK, your selected cell comment boxes have been auto-fitted to the comment contents.

Tip: This code cannot automatically resize the new comment boxes you add.


Auto-size comment box to fit its content in active sheet or all sheet 

You can try the AutoFit Comment utility of Kutools for Excel to automatically resize all comment boxes in active sheet or all sheets in Excel. Please do as follows.

Before applying Kutools for Excel, please download and install it firstly.

1. For auto resizing comment boxes to fit their content in active sheet, please click Kutools > More > AutoFit Comment > Active sheet.

And if you want to auto resize all comment boxes in the whole workbook, please click Kutools > More > AutoFit Comment > All sheets. See screenshot:

Then all comment boxes are automatically resized to fit their content. See screenshot:

Notes:

  • 1. After auto resizing the comment boxes, when editing the comment again, the comment box will automatically expand or shrink with the content.
  • 2. For the new comments you inserted, you need to enable this AutoFit comment utility again to resize all new inserted comment boxes.

  If you want to have a free trial (30-day) of this utility, please click to download it, and then go to apply the operation according above steps.


Easily auto-size comment box to fit its content


Related articles:

Best Office Productivity Tools

Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

kte tab 201905


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Comments (18)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Bom-dia,

Salvou de mais! Após abrir planilha no celular todos os comentários ficaram desajustados no pc.
Tinha mais de 10 mil comentários pra arrumar o tamanho da caixa! Se tivesse pix eu até pagava! Obrigado.
This comment was minimized by the moderator on the site
It doesn't work, the insert module does not show up
This comment was minimized by the moderator on the site
amazing! thank you, the first way works! saved me hours of work!
This comment was minimized by the moderator on the site
I guess Crystal got us off track the question was: Is there a way of making the line from the comment box to the cell darker or fatter? That would be the line surrounding the comment box. TIA DD
This comment was minimized by the moderator on the site
Is there a way of making the line from the comment box to the cell darker or fatter?
This comment was minimized by the moderator on the site
Hi Demondrew,
Sorry can help you for that.
This comment was minimized by the moderator on the site
Thank you so much for sharing this. Really helpful!
This comment was minimized by the moderator on the site
@DENNIE "While the code works it makes the box one line high meaning that large comments disappear off-page somewhere. Could you give the code for fixing the width of each box (to let's say three standard Excel column widths) and auto-adjusting the length of the box to fit the text? Thanks." // Agreed
This comment was minimized by the moderator on the site
Thank you very much. This really saved me from lots of hassles.
This comment was minimized by the moderator on the site
While the code works it makes the box one line high meaning that large comments disappear off-page somewhere. Could you give the code for fixing the width of each box (to let's say three standard Excel column widths) and auto-adjusting the length of the box to fit the text? Thanks.
This comment was minimized by the moderator on the site
It is really a nice and helpful piece of info. Im glad that you shared this helpful information with us. Please keep us up to date like this. Thanks for sharing. kdagekebeceddded
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations