
- MS Excel Basics
- Excel - Home
- Excel - Getting Started
- Excel - Explore Window
- Excel - Backstage
- Excel - Entering Values
- Excel - Move Around
- Excel - Save Workbook
- Excel - Create Worksheet
- Excel - Copy Worksheet
- Excel - Hiding Worksheet
- Excel - Delete Worksheet
- Excel - Close Workbook
- Excel - Open Workbook
- Excel - Context Help
- Editing Worksheet
- Excel - Insert Data
- Excel - Select Data
- Excel - Delete Data
- Excel - Move Data
- Excel - Rows & Columns
- Excel - Copy & Paste
- Excel - Find & Replace
- Excel - Spell Check
- Excel - Zoom In-Out
- Excel - Special Symbols
- Excel - Insert Comments
- Excel - Add Text Box
- Excel - Undo Changes
- Formatting Cells
- Excel - Setting Cell Type
- Excel - Setting Fonts
- Excel - Text Decoration
- Excel - Rotate Cells
- Excel - Setting Colors
- Excel - Text Alignments
- Excel - Merge & Wrap
- Excel - Borders and Shades
- Excel - Apply Formatting
- Formatting Worksheets
- Excel - Sheet Options
- Excel - Adjust Margins
- Excel - Page Orientation
- Excel - Header and Footer
- Excel - Insert Page Breaks
- Excel - Set Background
- Excel - Freeze Panes
- Excel - Conditional Format
- Working with Formula
- Excel - Creating Formulas
- Excel - Copying Formulas
- Excel - Formula Reference
- Excel - Using Functions
- Excel - Builtin Functions
- Advanced Operations
- Excel - Data Filtering
- Excel - Data Sorting
- Excel - Using Ranges
- Excel - Data Validation
- Excel - Using Styles
- Excel - Using Themes
- Excel - Using Templates
- Excel - Using Macros
- Excel - Adding Graphics
- Excel - Cross Referencing
- Excel - Printing Worksheets
- Excel - Email Workbooks
- Excel- Translate Worksheet
- Excel - Workbook Security
- Excel - Data Tables
- Excel - Pivot Tables
- Excel - Simple Charts
- Excel - Pivot Charts
- Excel - Keyboard Shortcuts
- MS Excel Resources
- Excel - Quick Guide
- Excel - Useful Resources
- Excel - Discussion
How to Auto-Size a Comment Box to Fit Its Content in Excel?
Have you ever wondered if there is any way in Excel to automatically size the comment box to fit its contents? This is only possible using the VBA application. Using VBA code, we can customise the sheet to automatically fit the size of the comment box to its contents in Excel. This tutorial will help you understand how we can automatically size comment boxes to fit their content in Excel.
Auto-Size a Comment Box to Fit Its Content in Excel
Here, we will first create a VBA module and then run it to complete our task. Let us see a simple process to understand how we can auto-size the comment box to fit its contents using the VBA application.
Step 1
Consider an Excel sheet with at least one comment present throughout the sheet, as shown in the image.

Now to open the VBA application, click on "Insert," select "Module," and enter the programme into the textbox as shown in the below image.
Example 1
Sub Comments() 'Update By Nirmal Dim xComment As Comment For Each xComment In Application.ActiveSheet.Comments xComment.Shape.TextFrame.AutoSize = True Next End Sub

Step 2
Now save the document as a macro-enabled sheet and click on F5 to run the code, and the comments will be adjusted as shown in the below image.

If you only want to auto-size the comments in a range of cells, then we can use Program 2 in the VBA application.
Example 2
Sub Fitrangecomments() 'Update By Nirmal Dim rng As Range Dim WorkRng As Range xTitleId = "Select the range" 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
Note − The above codes will only work for the existing comment boxes; they will not work for newly added comment boxes.
Conclusion
In this tutorial, we used a simple example to demonstrate how you can auto-size a comment box to fit its contents in Excel.
- Related Articles
- How to Auto-Fit Column Width in Excel?
- How to Auto Add Date and Time to Comment in Excel?
- How to change the shape of comment box in Excel?
- How to Auto-Fit Row Height of Merged Cells in Excel?
- How to Convert Text in Text Box to Cell Content in Excel?
- How to add comment to chart in Excel?
- How to add hyperlink to comment in Excel?
- How to Auto-Number a Column in Excel?
- How to Auto Change the Shape and Size Based on a Specified Cell Value in Excel?
- How to make a GridLayout fit screen size in Android?
- How to add comment to a data point in an Excel chart?
- How to Auto-Protect a Specific Worksheet in Excel?
- How to Auto-Update a Dropdown List in Excel?
- How to Auto-Populate Date in a Cell when its Adjacent Cell is Updated in Excel?
- How to set div width to fit content using CSS?
