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

Avoiding the Update Links Message

Word allows you to establish links from one document to another. When you open a document containing these links, you may ...

Discover More

Listing Combinations

You can easily use the COMBIN worksheet function to determine the number of combinations that can be made from a given ...

Discover More

Counting Document Lines

Need to know how many lines are in your document? Word provides a quick and easy way you can determine the information.

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

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

Automatic Row Height For Merged Cells with Text Wrap

When you have text wrap turned on in a cell, Excel expands the height of the row as you add more text to the cell. When ...

Discover More

Hiding and Unhiding Rows

When building a worksheet, you may need to hide some of the rows or unhide other, previously hidden, rows. It's easy to ...

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 nine minus 1?

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.