跳到主要内容

Excel:单击时如何展开单元格以显示所有内容

在某些情况下,如果单元格内容长于单元格的宽度并且下一列单元格中有值,则仅显示部分内容,如下图所示。 为避免更改单元格的宽度和高度,您可以单击单元格并在编辑栏中查看全部内容。 但是如果编辑栏被隐藏或者比内容短,怎么办呢? 这里介绍两种方法,可以在单击时在文本框中显示单元格内容。
从另一个列表自动完成

通过插入文本框来展开单元格以显示所有内容 Active X 控件

使用 Kutools for Excel 的更大公式栏展开单元格以显示所有内容

注意:本教程提供的方法均在 Excel 2021 中测试,在不同的 Excel 版本中可能会有一些不同。


通过插入文本框来展开单元格以显示所有内容 Active X 控件

1.激活要展开单元格的工作表,单击 开发商 > 插页 > 文本框(ActiveX 控件).
从另一个列表自动完成

如果没有 开发商 功能区中的选项卡,请先显示它,请查看本教程如何在 Excel 功能区中显示/显示开发人员选项卡

2. 然后拖动光标绘制一个宽高的文本框,可以显示最长的单元格内容。 记住这个文本框的名字,这里是TextBox1。
从另一个列表自动完成

3. 右键单击​​文本框,然后单击 查看房源 从上下文菜单中。 然后在 查看房源 窗格中,选择 从下拉列表中 多线自动换行 部分。 然后关闭 查看房源 窗格。
从另一个列表自动完成  从另一个列表自动完成

或者您可以从下拉列表中选择 True 自动尺寸 属性窗格中的部分,文本框将根据您单击的单元格内容的长度自动调整大小。

4. 右键单击​​状态栏中的工作表名称选项卡,然后单击 查看代码 从上下文菜单。

5.在 Microsoft Visual Basic应用程序 窗口,将下面的代码复制并粘贴到空白脚本中。

VBA:展开单元格以显示内容

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'UpdatebyExtendoffice
Dim xRgAddress As String
xRgAddress = "A1:B4" 'the range this VBA work, if you leave it is blank, it work for whole sheet
If xRgAddress = "" Then
  With TextBox1
        .Top = Target.Top
        .Left = Target.Offset(, 1).Left
        .Text = Target.Text
        .Visible = True
    End With
Else
    If Intersect(Target, Range(xRgAddress)) Is Nothing Then
        TextBox1.Visible = False
    Else
        With TextBox1
            .Top = Target.Top
           .Left = Target.Offset(, 1).Left
            .Text = Target.Text
            .Visible = True
        End With
    End If
End If
End Sub

从另一个列表自动完成

请注意,TextBox1 是您绘制的文本框的名称,而 A1:B4 是此代码的工作范围,请根据需要更改它们。

6.回到工作表,点击 开发商 > 设计模式 存在设计模式。
从另一个列表自动完成

现在,当您单击单元格时,文本框将出现在其旁边,并显示单元格的全部内容。
从另一个列表自动完成


使用 Kutools for Excel 的更大公式栏展开单元格以显示所有内容

如果您安装了 Kutools for Excel,当您单击时,它提供的更大的公式栏将在弹出框中显示单元格的所有内容,只要您通过单击激活它 库工具 > 更大的公式栏。
从另一个列表自动完成

提示:

1. 使用更大的公式栏,除了查看活动单元格的内容外,您还可以在更大的公式栏中编辑单元格内容。

2.您可以通过拖动栏的右下角来调整更大的公式栏的大小。

3. 如果您选择了多个单元格,则只有选择的第一个单元格的内容会显示在更大的公式栏中。

有关 Bigger Formula Bar 的更多详细信息,请访问其 教程.


其他操作(文章)

如何关闭自动完成
这是 Excel 中可以停止自动完成的选项。

如何减小 Excel 文件大小?
有时,如果 Excel 文件太大,打开或保存需要几分钟。 为了解决这个问题,在本教程中,它告诉您如何通过删除不必要或从未使用过的内容或格式来减小 Excel 文件的大小。

如何自动完成另一个表中的单元格
在本教程中,它讨论了如何在输入一个列值后从另一个表中的表格中自动完成其他列单元格。

如何在Excel中将阴影应用于奇数或偶数(替代)行/列?
在设计工作表时,许多人倾向于对奇数或偶数(替代)行或列应用阴影,以使工作表更直观。 本文将向您展示两种将阴影应用于Excel中奇数或偶数行/列的方法。


  • 超级公式栏 (轻松编辑多行文本和公式); 阅读视图 (轻松读取和编辑大量单元格); 粘贴到过滤范围...
  • 合并单元格/行/列 和保存数据; 拆分单元格内容; 合并重复的行和总和/平均值...防止细胞重复; 比较范围...
  • 选择重复或唯一 行; 选择空白行 (所有单元格都是空的); 超级查找和模糊查找 在许多工作簿中; 随机选择...
  • 确切的副本 多个单元格,无需更改公式参考; 自动创建参考 到多张纸; 插入项目符号,复选框等...
  • 收藏并快速插入公式,范围,图表和图片; 加密单元 带密码 创建邮件列表 并发送电子邮件...
  • 提取文字,添加文本,按位置删除, 删除空间; 创建和打印分页小计; 在单元格内容和注释之间转换...
  • 超级筛选 (将过滤方案保存并应用于其他工作表); 高级排序 按月/周/日,频率及更多; 特殊过滤器 用粗体,斜体...
  • 结合工作簿和工作表; 根据关键列合并表; 将数据分割成多个工作表; 批量转换xls,xlsx和PDF...
  • 数据透视表分组依据 周号,周几等 显示未锁定的单元格 用不同的颜色 突出显示具有公式/名称的单元格...
kte选项卡201905
  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
officetab底部
Comments (5)
Rated 4.5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
I am having the same issue as Neil. Code works fine, except when selecting any full row or column that include the cell range in the code, i am getting the Run-time error '94'. Invalid use of Null, highlighting to .Text = Target.Text. This code was very helpful except for the debug popping up every time. Please provide a solution
This comment was minimized by the moderator on the site
Hi, I have modified the code, it will not pop up a bug dialog when you select a column of cells or multiple cells, and the textbox will be hidden as well. Please try:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'UpdatebyExtendoffice
Dim xRgAddress As String
If Target.CountLarge > 1 Then
    TextBox1.Visible = False
    Exit Sub
End If
xRgAddress = "A1:A20" 'the range this VBA work, if you leave it is blank, it work for whole sheet
If xRgAddress = "" Then
  With TextBox1
        .Top = Target.Top
        .Left = Target.Offset(, 1).Left
        .Text = Target.Text
        .Visible = True
    End With
Else
    If Intersect(Target, Range(xRgAddress)) Is Nothing Then
        TextBox1.Visible = False
    Else
        With TextBox1
            .Top = Target.Top
           .Left = Target.Offset(, 1).Left
            .Text = Target.Text
            .Visible = True
        End With
    End If
End If
End Sub
This comment was minimized by the moderator on the site
Sunny, this is absolutely perfect - thank you so much for your time and expertise.
This comment was minimized by the moderator on the site
Good day, this code is great - I have two columns included in my code and the expanding text box pops up no issues when a cell is clicked - however, if I highlight multiple cells including one of the cells I wish to have the text box pop up - I get run-time error '94' - Invalid use of Null. Debugging highlights the 2nd 'Text = Target.Text' line.

Appreciate any feedback.
Rated 4.5 out of 5
This comment was minimized by the moderator on the site
Hi, do you want to show all contents of the selected cells to the textbox? Or just supports to select cells but show contents of the first one cell of the selection?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations