Log in  \/ 
x
or
x
x
Register  \/ 
x

or

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

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

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

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.


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  (just one click)

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.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days.

1. For auto resizing comment boxes 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.

Tip.If you want to have a free trial of this utility, please go to download the software freely first, and then go to apply the operation according above steps.


Auto-size comment box to fit its content with Kutools for Excel

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 60 days. Download the free trial now!


Related articles:


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
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!
officetab bottom
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Shubham · 4 months ago
    Thank you so much for sharing this. Really helpful!
  • To post as a guest, your comment is unpublished.
    Paul · 2 years ago
    @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
  • To post as a guest, your comment is unpublished.
    R.R. · 3 years ago
    Thank you very much.

    This really saved me from lots of hassles.
  • To post as a guest, your comment is unpublished.
    Dennie · 3 years ago
    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.
  • To post as a guest, your comment is unpublished.
    Smithe636 · 3 years ago
    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
  • To post as a guest, your comment is unpublished.
    Joe · 3 years ago
    Good! Solved my issue.
  • To post as a guest, your comment is unpublished.
    Laure · 3 years ago
    "VBA code: Auto-size comment boxes in a worksheet" took care of my spreadsheet's comments. Thanks so much!
  • To post as a guest, your comment is unpublished.
    John · 3 years ago
    I get an error:

    Run-time '1004':
    Method AutoSize of object TextFrame failed
  • To post as a guest, your comment is unpublished.
    Jeremy · 4 years ago
    this didn't work at all. I got a error repeatedly.
  • To post as a guest, your comment is unpublished.
    david · 4 years ago
    It did not work like the first code you sent it only fit the content what i want is something that will make them all the same width and the length will auto fit the content

    as this is how column H looks right now and column A varies in width size

    would like column A to be three columns wide and length to fit content and grow as needed when you hit enter the box length should grow by a line is there a code for that ? note i tried both key cod that page you sent last.
  • To post as a guest, your comment is unpublished.
    Vaibhav · 5 years ago
    Using your code
    1.
    Dim xComment As Comment
    For Each xComment In Application.ActiveSheet.Comments
    xComment.Shape.TextFrame.AutoSize = True
    Next
    2. issue with this error occur 445 object reference
    With Range("A1").Comment.Shape.TextFrame2
    .WordWrap = msoTrue
    .AutoSize = msoAutoSizeTextToFitShape
    End With
  • To post as a guest, your comment is unpublished.
    archa · 5 years ago
    Thanks you. Easy and quick solution for my problem.