Cookies help us deliver our services. By using our services, you agree to our use of cookies.
Tip: Other languages are Google-Translated. You can visit the English version of this link.
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


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:



Recommended Productivity Tools

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 300 New Features for Excel, Make Excel Much Easy and Powerful:

  • Merge Cell/Rows/Columns without Losing Data.
  • Combine and Consolidate Multiple Sheets and Workbooks.
  • Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
  • Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
  • More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...

Screen shot of Kutools for Excel

Say something here...
symbols left.
You are guest ( Sign Up? )
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.
    Paul · 1 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. · 1 years ago
    Thank you very much.

    This really saved me from lots of hassles.
  • To post as a guest, your comment is unpublished.
    Dennie · 1 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 · 2 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 · 2 years ago
    Good! Solved my issue.