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:
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:
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:
- How to change the shape of comment box in Excel?
- How to change all comment formats in cells in Excel?
- How to list all comments to a new worksheet or workbook in Excel?
- How to insert picture or image in comment in Excel?
Best Office Productivity Tools
Supports Office/Excel 2007-2021 and 365 | Available in 44 Languages | Easy to Uninstall Completely
Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need Is Just A Click Away...
Supercharge Your Excel Skills: Experience Efficiency Like Never Before with Kutools for Excel (Full-Featured 30-Day Free Trial)
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! (Full-Featured 30-Day Free Trial)


















