Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
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 '09 at 8:57

8 Answers 8

Try

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

share|improve this answer
1  
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 '09 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 '09 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. –  Li-aung Yip Mar 2 '12 at 2:21

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

share|improve this answer

Do you know macro? Put the following code in

Application.ActiveCell.WrapText = True

inside your Worksheet_SelectionChange subroutine.

share|improve this answer

A VBA solution is to use the following:

 Call Application.ActiveCell.AutoFit
share|improve this answer

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

share|improve this answer

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.

share|improve this answer

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][1]http://support.microsoft.com/kb/212010

share|improve this answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.