跳到主要內容

Excel:單擊時如何展開單元格以顯示所有內容

在某些情況下,如果單元格內容長於單元格的寬度並且下一列單元格中有值,則僅顯示部分內容,如下圖所示。 為避免更改單元格的寬度和高度,您可以單擊單元格並在編輯欄中查看全部內容。 但是如果編輯欄被隱藏或者比內容短,怎麼辦呢? 這裡介紹兩種方法,可以在單擊時在文本框中顯示單元格內容。
從另一個列表自動完成

通過插入文本框來展開單元格以顯示所有內容 Active X 控件

使用 Kutools for Excel 的更大的公式欄展開單元格以顯示所有內容

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


通過插入文本框來展開單元格以顯示所有內容 Active X 控件

1.激活要展開單元格的工作表,單擊 開發者 > 插入 > 文本框(ActiveX 控件).
從另一個列表自動完成

如果沒有 開發者 功能區中的選項卡,請先顯示它,請查看本教程如何在 Excel 功能區中顯示/顯示開發人員選項卡

2. 然後拖動光標繪製一個寬高的文本框,可以顯示最長的單元格內容。 記住這個文本框的名字,這裡是TextBox1。
從另一個列表自動完成

3. 右鍵單擊文本框,然後單擊 氟化鈉性能 從上下文菜單中。 然後在 氟化鈉性能 窗格中,選擇 從下拉列表中 多行自動換行 部分。 然後關閉 氟化鈉性能 窗格。
從另一個列表自動完成  從另一個列表自動完成

或者您可以從下拉列表中選擇 True 自動尺寸 屬性窗格中的部分,文本框將根據您單擊的單元格內容的長度自動調整大小。

4. 右鍵單擊狀態欄中的工作表名稱選項卡,然後單擊 查看代碼 從上下文菜單。

5。 在裡面 Microsoft Visual Basic for Applications 窗口,將下面的代碼複製並粘貼到空白腳本中。

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