跳到主要内容

如何自动调整注释框的大小以适合Excel中的内容?

当您将注释插入单元格时,注释框的大小是默认大小。 如果您在其中输入很多内容,则某些内容将不会直接可见。 是否可以自动使注释框的大小适合其内容?

自动调整注释框大小以使其适合工作表中的内容
自动调整注释框大小以使其内容适合一系列单元格
借助令人惊叹的工具轻松调整注释框的大小,使其适合活动工作表或所有工作表中的内容


自动调整注释框大小以使其适合工作表中的内容

在Excel中,您可以手动将注释框一一拖到所需的大小,但是如果有许多注释框需要调整大小,这种方法将很繁琐且耗时。 在这种情况下,您可以应用以下VBA代码。

1.按住 ALT + F11 键,然后打开 Microsoft Visual Basic for Applications窗口.

2。 点击 插页 > 模块,然后将以下宏粘贴到 模块窗口.

VBA代码:自动调整工作表中的注释框的大小

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

3.然后按 F5 键以运行此代码,并且活动工作表中的所有注释框都已调整大小以适合其内容,如以下屏幕截图所示:

doc自动调整大小comment1

Tips::此代码仅在当前工作表中起作用,并且无法自动调整添加的新注释框的大小。


一键快速将注释框的大小自动调整为适合Excel中的内容:

自动评论 实用程序 Kutools for Excel 可以帮助在工作表中自动使注释框的大小自动适应其内容,如下面的演示所示。 立即下载并试用! (30 天免费试用)


自动调整注释框大小以使其内容适合一系列单元格

如果只需要自动调整一系列单元格注释框的大小,则可以使用以下VBA代码。

1.按住 ALT + F11 键,然后打开 Microsoft Visual Basic for Applications窗口.

2。 点击 插页 > 模块,然后将以下宏粘贴到 模块窗口.

VBA代码:在一系列单元格中自动调整注释框的大小

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.然后按 F5 键以执行此代码,然后会出现一个提示框,提醒您选择要调整注释框大小的单元格范围,请参见屏幕截图:

文档调整大小评论框3

4.然后单击 OK,您选择的单元格注释框已自动适应注释内容。

Tips::此代码无法自动调整您添加的新注释框的大小。


自动调整注释框的大小以使其内容适合活动工作表或所有工作表 

你可以试试 自动调整评论 实用程序 Kutools for Excel 自动调整大小活动工作表中的注释框或Excel中的所有工作表。 请执行以下操作。

申请前 Kutools for Excel首先下载并安装.

1.要自动调整注释框的大小以使其适合活动工作表中的内容,请单击 库工具 > 更多 > 自动调整评论 > 活动表.

如果要自动调整整个工作簿中所有注释框的大小,请单击 库工具 > 更多 > 自动调整评论 > 所有工作表。 看截图:

然后,所有评论框都会自动调整大小以适合其内容。 看截图:

:

  • 1.自动调整注释框的大小后,再次编辑注释时,注释框将随内容自动扩展或缩小。
  • 2.对于您插入的新注释,您需要再次启用此AutoFit注释实用程序以调整所有新插入的注释框的大小。

  如果您想免费试用(30天)此实用程序, 请点击下载,然后按照上述步骤进行操作。


轻松自动调整注释框大小以适合其内容


相关文章:

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (19)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi. I've been using an xls spreadsheet for 10+ years. Suddenly, all my note boxes were hugely expanded, showed as a blank note until I edited them. Your solution below worked to resize all of my note boxes to fit contents. But now when I try to resize the note box to add more text, Excel crashes. This is even after I saved as an xlsx file to remove all VB code. Can you help?

Sub FitComments()
'Updateby20140325
Dim xComment As Comment
For Each xComment In Application.ActiveSheet.Comments
xComment.Shape.TextFrame.AutoSize = True
Next
End Sub
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.
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