How can I get a cell in Excel to automatically adjust its height to fit the wrapped text contents?

23

6

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?

Manga Lee

Posted 2009-08-25T08:54:21.203

Reputation: 971

Question was closed 2016-02-07T08:55:14.657

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 – 2009-08-25T08:57:48.997

Answers

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

vaichidrewar

Posted 2009-08-25T08:54:21.203

Reputation: 998

11

Try

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

hyperslug

Posted 2009-08-25T08:54:21.203

Reputation: 12 882

It worked for me on Excel 2019. – 猫IT – 2019-03-06T14:39:34.353

2The 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 – 2009-08-25T09:21:07.903

3I'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 – 2009-08-25T10:12:53.773

+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. – Li-aung Yip – 2012-03-02T02:21:45.613

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

abruti

Posted 2009-08-25T08:54:21.203

Reputation: 72

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).

Lance Roberts

Posted 2009-08-25T08:54:21.203

Reputation: 7 895

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 – 2019-03-06T14:41:49.440

0

Do you know macro? Put the following code in

Application.ActiveCell.WrapText = True

inside your Worksheet_SelectionChange subroutine.

Toc

Posted 2009-08-25T08:54:21.203

Reputation: 1 663

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.

simpleuser

Posted 2009-08-25T08:54:21.203

Reputation: 478

0

A VBA solution is to use the following:

 Call Application.ActiveCell.AutoFit

richardtallent

Posted 2009-08-25T08:54:21.203

Reputation: 1 052

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

Mickg01

Posted 2009-08-25T08:54:21.203

Reputation: 1