Skip to main content

Excel: How to expand cell to show all contents when click

In some cases, if the cell content is longer than the width of the cell and there are values in the next column cells, only parts of content are shown as the below screenshot shown. For avoiding changing the width and height of the cells, you can click the cell and view whole contents in the formula bar. But if the formula bar is hidden or shorter than the contents, how to do it? Here introduces two methods which can show the cell content in a textbox when clicking at it.
auto complete from another list

Expand cell to show all contents by insert a textbox Active X Controls

Expand cell to show all contents by using Bigger Formula Bar of Kutools for Excel

Note: the methods provided in this tutorial are tested in Excel 2021, there may be some different in different Excel verisions.


Expand cell to show all contents by insert a textbox Active X Controls

1. Activate the worksheet that you want to expand cell, click Developer > Insert > Text Box (ActiveX Controls).
auto complete from another list

If there is no Developer tab in the ribbon, please display it at first, please view this tutorial How To Show/Display Developer Tab In Excel Ribbon

2. Then drag the cursor to draw a textbox with a width and height which can show the longest contents of cells. Remember this textbox’s name, here is TextBox1.
auto complete from another list

3. Right-click at the textbox, and click Properties from the context menu. Then in Properties pane, choose True from drop-down lists in the MultiLine and WordWrap sections. Then close the Properties pane.
auto complete from another list  auto complete from another list

Or you can select True from the drop-down list in AutoSize section in Properties pane, the textbox will be auto sized based on the length of the cell contents you click.

4. Right-click at the sheet name tab in the status bar, and click View Code from the context menu.

5. In the Microsoft Visual Basic for Applications window, copy and paste below code to the blank script.

VBA: Expand cell to show contents

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

auto complete from another list

Notice that TextBox1 is the name of the textbox you drew, and A1:B4 is the range this code work, change them as you need.

6. Go back to the sheet, click Developer > Design Mode to exist design mode.
auto complete from another list

Now when you click at the cell, the textbox will appear next to it, and show whole contents of the cell.
auto complete from another list


Expand cell to show all contents by using Bigger Formula Bar of Kutools for Excel

If you have installed Kutools for Excel, the Bigger Formula Bar it provided will show all contents of the cell in a popped box when you click as long as you active it by clicking Kutools > Bigger Formula Bar.
auto complete from another list

Tips:

1. With the Bigger Formula Bar, except to view contents of the active cell, also you can edit the cell contents in the Bigger Formula Bar.

2. You can resize the Bigger Formula Bar by dragging the right down corner of the Bar.

3. If you select more than one cells, only the contents of the first cell of the selection are shown in Bigger Formula Bar.

More details about Bigger Formula Bar, please visit its tutorial.


Other Operations (Articles)

How To Turn Off Auto Complete
Here is an option in Excel that can stop the auto complete.

How To Reduce Excel File Size?
Sometimes, it will take minutes to open or save if the Excel file is too large. For solving this problem, here in this tutorial, it tells you how to reduce the Excel file size by removing the contents or formats which are unnecessary or never used.

How To Auto Complete Cells From Another Table
In this tutorial, it is talking about how to auto complete other column cells from a table in another sheet after entering one column value.

How to apply shading to odd or even (alternative) rows/columns in Excel?
While designing a worksheet, many people tend to apply shading to odd or even (alternative) rows or columns in order to make the worksheet more visual. This article will show you two methods to apply shading to odd or even rows/columns in Excel.


  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns and Keeping Data; Split Cells Content; Combine Duplicate Rows and Sum/Average... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Favorite and Quickly Insert Formulas, Ranges, Charts and Pictures; Encrypt Cells with password; Create Mailing List and send emails...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • Pivot Table Grouping by week number, day of week and more... Show Unlocked, Locked Cells by different colors; Highlight Cells That Have Formula/Name...
kte tab 201905
  • 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!
officetab bottom
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