How to make Excel cells expand to fit text automatically

Excel cells can be set to automatically expand to fit the text. This can be useful for making sure that all of the text in a cell is visible, and for preventing cells from becoming too narrow and causing the text to wrap.

To do this, you can insert a simple code snippet using VBA:

You can easily do this by using VBA. To do that, Right click on the Sheet tab -> View Code.

Insert the following code in the VBA window:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Cells.EntireColumn.AutoFit
End Sub

Now if you return back to the Excel sheet, you will find that the text will autofit into the cells.

By using the code snippet, you can quickly and easily make Excel cells expand to fit text automatically. It saves you from the manual effort of adjusting cell sizes individually, especially when dealing with a large number of cells or frequently changing data.

Alternatively, if you want to autofit cells without code, you can follow these steps:

To make Excel cells expand to fit text automatically, follow these steps:

  1. Select the cells that you want to autofit.
  2. Click the Home tab.
  3. In the Cells group, click the Format button -> Autofit Column Width

By following these steps, you can make Excel cells expand to fit text automatically, saving you time and effort. This feature ensures that your spreadsheet remains well-organized and easy to read, even when dealing with varying text lengths within cells.