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.

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


5

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:

  • The cell in which you are wrapping text is actually merged with another cell.
  • The height of the row in which the cell is located was previously changed.

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:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

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.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Defining Default Printers on a Document Level

If you use multiple printers, you may wonder how to set each document in Word to remember which printer to use for that ...

Discover More

Changing Dialog Box Pull-Down List Item Order

When selecting options within dialog boxes, Word frequently uses drop-down lists to display the options. While ...

Discover More

Nifty Zooming

If you are using a mouse that has a center wheel, you can use the wheel to zoom in and out of your work. This tip shows ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Adjusting Row Height when Wrapping Text

If you have some cells merged in a worksheet, and you wrap text within that merged cell, Excel won't automatically resize ...

Discover More

Adjusting Row Height for a Number of Worksheets

Adjusting the height of a row or range of rows is relatively easy in Excel. How do you adjust the height of those same ...

Discover More

Adjusting to a Maximum Row Height

Need to check the height of all the rows in a worksheet and then adjust them if a particular criterion is met? This tip ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one less than 9?

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!


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.