Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. 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: Setting Row Height in a Macro.
by Allen Wyatt
(last updated June 21, 2018)
It is not unusual to use macros to process data and format output in an workbook. If you use macros to do this type of work, you may be interested in changing the height of a row using a macro. If so, you should pay attention to the RowHeight property. This property, when applied to a Row object, indicates the height of the row in points.
For instance, the following code snippet steps through the rows in a selection and sets the height of each row to 36 points (one-half inch):
For Each r In ActiveWindow.RangeSelection.Rows r.RowHeight = 36 Next r
If you prefer not to step through each of the rows, you could use the following single line to adjust the row height:
Selection.RowHeight = 36
Either approach sets the height of all the rows that were selected when the code is executed. If you want your macro to adjust a specific range of rows, then you can specify the rows directly in the code:
ActiveSheet.Rows("3:34").RowHeight = 36
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9239) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Setting Row Height in a Macro.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
Need to figure out an absolute value within your macro code? It's easy to do using the Abs function, described in this tip.Discover More
What is a macro? Ever wonder what these are and how to use them? This tip answers the basics of what a macro is used for, ...Discover More
Need to know the address of the cell that is currently selected? The function and macro highlighted in this tip will come ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.