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.
Written by Allen Wyatt (last updated February 23, 2019)
This tip applies to Excel 97, 2000, 2002, and 2003
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.)
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.
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!
When you format a cell so that the information within it can wrap to multiple lines, you may be surprised if Excel ...
Discover MoreIt'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 MoreAdjusting the height of a row or range of rows is relatively easy in Excel. How do you adjust the height of those same ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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
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.
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.
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