Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Automatic Row Height for Wrapped Text.
Written by Allen Wyatt (last updated October 31, 2020)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
Jordan formatted some cells in his worksheet to wrap text within them. Even though the text in the cells wraps, Excel won't automatically adjust the row height to show all the wrapped text. Jordan wonders if there is a way to "reset" the row so that Excel will adjust its height based on the text being wrapped within the cells.
By default, when you wrap text within a cell, Excel automatically adjusts row height so that all the text in the cell is visible. There are only two exceptions to this default:
In Jordan's case, there are no merged cells in the problem row. This leaves us with the second exception—it would appear that the height of the row in which the cell is located was explicitly set before wrapping was turned on in some of the row's cells.
In this case, the solution is simple: Reset the row height. There are actually a couple of ways you can do this. First, you could select the row and then double-click the "boundary" between the row and an adjacent row. With the row selected, take a look at the row header, to the left of column A. This area contains a row number, and the "boundary" you need to double-click is between this row number and the next row number.
It can be a bit tricky to get the mouse pointer in the correct location to do the double-clicking, so an approach I prefer is to select the row and display the Home tab of the ribbon. In the Cells group there is a Format tool; I click it and then choose AutoFit Row Height. This allows Excel to determine the appropriate row height based on the contents of the row. If a cell in the row has wrapping turned on, then the row height will automatically adjust to display the information in the cell.
If you have quite a few rows that contain cells with wrapping turned on, and the height of none of the rows is adjusting, then you may be interested in a quick little macro that can do the adjustment for you:
Sub AutofitRows() Dim c As Range For Each c In ActiveSheetUsedRange If c.WrapText Then c.Rows.AutoFit Next c End Sub
The macro steps through all the cells in a worksheet, and if the cell has wrapping turned on, it sets the AutoFit property of the row in which the cell is located.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10735) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Automatic Row Height for Wrapped Text.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!
When building a worksheet, you may need to hide some of the rows or unhide other, previously hidden, rows. It's easy to ...
Discover MoreChanging the default row height used for a worksheet is relatively easy, as long as you don't mind the row height never ...
Discover MoreWant to set the width and height of a row and column by specifying a number of inches? It's not quite as straightforward ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2021-01-31 04:07:15
Rohn S, MVP 2012-2018
Hi John:
Maybe you are right. But the macro works the way it is to do what I want, so I'm not going to mess with success <g> .
Play with it and let us know what find.
2021-01-30 16:06:04
John Mann
@Ron S
I'm a raw novice with macros, so maybe I'm not understanding something in your second version. If I understand correctly what you are doing, it's to both apply the "wrap text" property, and the "Automatic Row Height".
If I'm reading you macro correctly (big If), then you test for if the text is wrapped and if so then apply Autofit. Later you set the wrap text. Shouldn't the wrap text be set first?
Please note that at this point I haven't done any testing - just read the tip.
I've been having trouble with these features in some tables (formated as such) in Excel 2010. I've set the wrap text property for entire columns, and likewise the Autofit Row Height for the entire columns (from the ribbon), but sometimes find new entries don't have the Auto Fit Row Height applied, and have to do it again. Macros of this type, run from my rather long QAT would be useful.
This is one tip which will be printed and added to my collection of printed tips
2020-11-03 13:11:51
william driskell
shortcut - if you click in upper left corner of the sheet's margin to "select entire sheet," then click any row's upper/lower edge in the left margin, you will auto-adjust the entire sheet instead of a single row.
I usually like to auto-adjust all row heights after widening a column for some awkwardly wrapped text content. Must be some pysch phenomena but I find it easier to visually scan through data when they're all in similar cells --or maybe it's just OCD showing up in formatting...
2020-11-01 07:43:44
Ron S MVP
I've since tweaked the macro some more to now apply the WrapText attribute.
Sub AutoFitRowHeight()
' https://excelribbon.tips.net/T010735_Automatic_Row_Height_for_Wrapped_Text.html
'
' Select the area to be affected
' Loop through all rows in current sheet, turn on AutoFit Row Height attribute
' Turn on Wrap attribute to resize rows
'
Dim c As Range
For Each c In ActiveSheet.UsedRange
If c.WrapText Then c.Rows.AutoFit
Next c
With Selection
.WrapText = True
End With
End Sub
I tried adding c.Rows.WrapText=True inside the "IF", but it didn't work. I had to move as above.
2020-10-31 10:30:13
Ron S MVP
Oops, typo:
For Each c In ActiveSheetUsedRange
Should be:
For Each c In ActiveSheet.UsedRange
This is definitely something I didn't know I needed. But now that I have it, it is on my QAT now and I'll be using it, A LOT!
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments