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?
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
Note that autofit doesn't work on merged cells. You have to do it manually.
See this Microsoft 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