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.
Note: the methods provided in this tutorial are tested in Excel 2021, there may be some different in different Excel verisions.
1. Activate the worksheet that you want to expand cell, click Developer > Insert > Text Box (ActiveX Controls).
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.
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.
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
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.
Now when you click at the cell, the textbox will appear next to it, and show whole contents of the cell.
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.
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.