Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Automatic Row Height For Merged Cells with Text Wrap.

Automatic Row Height For Merged Cells with Text Wrap

Written by Allen Wyatt (last updated February 23, 2019)
This tip applies to Excel 97, 2000, 2002, and 2003


7

Ernie asked if there was a way for Excel to automatically adjust the row height in cells that are merged. He points out that if a cell is set with text wrapping turned on, that Excel automatically adjusts the row height for the cell so that all the wrapped text is visible. If you subsequently merge that cell with an adjacent cell, even if the adjacent cell has text wrapping turned on, then the resulting merged cell's row height is not adjusted so that all the text is visible.

Exactly why Excel does this is unclear, but there is no intrinsic way around it—Excel just does it. At first blush you may think that you can use the AutoFit feature (Format | Rows | AutoFit) to adjust the height of the row in which the merged cell is located. Doing so, however, apparently has no affect—AutoFit seems to completely ignore merged cells in doing its magic.

One way around the problem is to use a macro to set the row height to the desired height. A good approach is to have the macro determine the column width of the merged area, unmerge the columns, set the first column to that width, and determine the row height required to AutoFit it. The macro could then reset the column width, merge the cells, and set the new row height. (If that sounds like a lot, it is. Such a macro wouldn't be that trivial to create.)

If you don't want to use a macro, you can fool Excel into setting the row height properly. You do this by using a separate column that is created for the express purpose of setting row height. The process is described in the following general steps. (These steps assume you are merging the cells in columns A and B, and that your data table only includes columns A through K.)

  1. Merge the cells in columns A and B as desired.
  2. In column Z (or some other column outside of your data table range, but not immediately adjacent), put a simple formula reference to column A, as in =A1.
  3. Ensure the text formatting of column Z is exactly the same as in the merged cell, with the exception of merging. (Column Z should not be merged with anything, nor should it be marked as merged.)
  4. Make the width of column Z slightly narrower than the combined width of columns A and B.

The effect of these steps is that Excel will set the row height based upon the contents of column Z, which just happen to match the contents of the merged cell in columns A and B. This, of course, allows all the text in the merged cell to be visible. The only thing you will need to do is make sure that you don't print the contents of column Z when you do your printing.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3207) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Automatic Row Height For Merged Cells with Text Wrap.

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

Accessing a Problem Shared Workbook

What are you to do is you share a workbook with others, and then suddenly the workbook won't open properly? Dealing with ...

Discover More

Allowing Only Form Field Changes

Word allows you to create forms that other people can use to enter information. One of the last steps normally taken with ...

Discover More

Jumping to the End of Page after Enter

Imagine you start typing in a new document, and when you press the Enter key the cursor jumps a huge distance to the ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

Automatic Row Height for Wrapped Text

When you format a cell so that the information within it can wrap to multiple lines, you may be surprised if Excel ...

Discover More

Hiding Rows Based on Two Values

It's easy to use filtering to hide rows based on the value in a cell, but how do you hide rows based on the values in two ...

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
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 7 + 3?

2024-03-23 23:29:32

Peter

I had a similar problem today, wanting to wrap rows of text at the right hand page boundary. The difference was that each row started in a different column. The data came from another app as a CSV file and when imported into Excel the column widths were too big and the text quite long. Once I reduced the column width to 1 or 2 characters, all the rows looked like they would fit nicely on a page once I merged and wrapped the cells starting with the first filled cell out to the page boundary in column X.

I used the column Z trick, but I extended it so that Z:AO contained a literal copy of B:Q.

The problem came in determining the total width of the cells to be merged on each row and then to set the correct with for the cell in columns Z:AO. A macro was the best I could do.


2020-08-21 13:01:02

BHRS

great method! you saved me :)


2020-05-27 12:35:47

Derek

Great trick thanks


2019-12-09 20:51:32

Bill Doyle

I love the tip for "tricking" Excel to format row height with merged cells + word wrap. Problem... I have a spreadsheet where I needed to merge row-cells across 40 columns, creating wide merged cells for taking cumulative notes over multiple meetings. The text in the cell cuts off at about column 30 with the "column Z" trick, thus no word-wrap.

It's hard to explain this, but simple if you see it... I'm happy to send the spreadsheet to talk thru the problem with someone who thinks they can help. My e-mail is: billder99@gmail.com


2019-04-26 10:03:24

Pamela Dewener

Using column Z - simple and genius! Thank you.


2019-02-28 03:14:04

Sadeesh

Thanks Allen. Such a cool method. Really helped.

Regards,

Sadeesh


2019-02-24 13:55:53

Vasile Bujder

I have a slightly different approach on this problem: in an empty cell on the same row (no matter wether it's inside or outside of data table range), I put just an Alt+Enter. I only ensure the font size in that cell is the same as in the merged cell. So I don't care if that cell gets printed. Just make sure the new cell does not affect the print area, if it's outside of data table range.


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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.