25

I have a cell with wrapped text content in Excel and I want to format the cell so that its height will adjust to fit the content which can span over several lines. How can I achieve this behavior?

1
  • not sure about excel 2007, but I am using excel 2003 and there that goes automatically, when I input multi-line data in a cell, the line height gets fixed when I press enter.
    – fretje
    Aug 25, 2009 at 8:57

8 Answers 8

27

From http://support.microsoft.com/kb/149663

To adjust the height of the row to fit all the text in a cell, follow these steps:

Select the row.

In Microsoft Office Excel 2003 and in earlier versions of Excel, point to Row on the Format menu, and then click AutoFit.

In Microsoft Office Excel 2007, click the Home tab, click Format in the Cells group, and then click AutoFit Row Height.

Also Works when all the rows are selected

12

Try

Select the column -> right-click column -> Format Cells -> Alignment tab -> Wrap text

4
  • 2
    The cell already has this formatting and I want the cell to also adjust its height. I want the height of the cell's row to adjust so that the whole wrapped content of the cell is visible.
    – Manga Lee
    Aug 25, 2009 at 9:21
  • 3
    I'm not sure if you can make this happen as the contents of the cell change, but once your finished double clicking on the border between the row number and the one below auto sizes it to fit the contents.
    – Col
    Aug 25, 2009 at 10:12
  • +1: This is not a bad answer. If you toggle Wrap Text off and on again, Excel will resize the row height to fit the tallest row. Not suitable if the height of rows is changing dynamically but if you're dealing with static text it should be OK. Mar 2, 2012 at 2:21
  • It worked for me on Excel 2019.
    – 猫IT
    Mar 6, 2019 at 14:39
4

Note that autofit doesn't work on merged cells. You have to do it manually.

See this Microsoft answer:

You cannot use the AutoFit feature for rows or columns that contain merged cells in Excel

2

If it doesn't automatically do it, then place your cursor over the small line between row numbers (ex: between 1 and 2) and double click, this will resize the row (directly above the small line, in the example: 1) so that everything is visible (from a vertical aspect).

1
  • That's something you can do when you have little of this to do but the more complex the more you'll have to deal with that and that means waste of time and energy, getting focus and momentum broken because of such tasks. The solution given by Bertieb works like a charm on Excel 2019.
    – 猫IT
    Mar 6, 2019 at 14:41
0

Do you know macro? Put the following code in

Application.ActiveCell.WrapText = True

inside your Worksheet_SelectionChange subroutine.

0

A VBA solution is to use the following:

 Call Application.ActiveCell.AutoFit
0

The only way I can get it to work as expected is to highlight the whole sheet with CTRL-A, unclick the "Wrap Text" button in the toolbar, then re-select it. No other settings change, but each row is now the "proper" height for its contents.

0

I created the following VB code to resize the header row when a cell within a range (B2:B1500) because date values above 12/28/2014 would cause the header to show a warning that these dates, in a timesheet, would go into Week1 of 2015:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range

    ' The variable KeyCells contains the cells that will
    ' cause an Action when they are changed.
    Set KeyCells = Range("B2:B1500")

    If Not Application.Intersect(KeyCells, Range(Target.Address)) _
           Is Nothing Then

        ' Change the height of the header row when one of the defined cdlls is changed
        Rows("1:1").EntireRow.AutoFit

    End If
End Sub

Not the answer you're looking for? Browse other questions tagged .