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: Setting Row Height in a Macro.

Setting Row Height in a Macro

Written by Allen Wyatt (last updated March 30, 2019)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


4

It is not unusual to use macros to process data and format output in a 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

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 (9239) 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: Setting Row Height in a Macro.

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

Size Limit for Documents

Word can handle large documents, but how large is large? This tip examines the issue and provides some advice on how ...

Discover More

Setting a Length Limit on Cells

Limiting what can be entered in a cell can be an important part of developing a worksheet that other people use. Here's a ...

Discover More

Getting the Name of the Worksheet Into a Cell

Excel allows you to change the names assigned to the worksheets in a workbook. If you want to have those names appear in ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Enforcing Moving Cells Up

When you design your worksheets, you probably want users to interact with those worksheets in specific ways. What ...

Discover More

Checking for the Existence of a File

The data stored in a worksheet can often correspond to information external to that worksheet. For instance, you might ...

Discover More

Removing a Directory

Macros allow you to perform all sorts of file-related operations. One such operation allows you to delete a directory. ...

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 6 - 0?

2021-04-14 12:00:03

J. Woolley

@Rachel
I will try to fix the first part of my previous comment here:

The first two code snippets in the Tip use RangeSelection and Selection. In either case, to set the height of rows 26, 31, 36:
1. Click the mouse to select any cell in row 26.
2. Ctrl+Click the mouse to select any cell in row 31.
3. Ctrl+Click the mouse to select any cell in row 36.
4. Run the macro.
Using Ctrl+Click adds each individual cell to the Selection.

Also, see https://sites.google.com/view/MyExcelToolbox/


2021-04-14 06:41:07

Harold Druss

Every 5th row should be:
For r = 5 To 50 Step 5
Rows(r).RowHeight = 80
Next


2021-04-13 12:41:44

J. Woolley

@Rachel The first two code snippets in the Tip use RangeSelection and Selection. In either case, to set the height of rows 26, 31, 36:1. Click the mouse to select any cell in row 26.2. Ctrl+Click the mouse to select any cell in row 31.3. Ctrl+Click the mouse to select any cell in row 36.4. Run the macro.Using Ctrl+Click adds each individual cell to the Selection.To set the height to 80 for every 5th row from 1 to 1001:For r = 1 To 1001 Step 5    Rows(r).RowHeight = 80Next rAlso, see https://sites.google.com/view/MyExcelToolbox/


2021-04-12 13:22:17

Rachel K

What about using the multiple row codes for rows that aren't connected? I want to set the row height for row 26, 31, 36. Do I have to do that individually? Futhermore, is there a way to automate every "certain" row as a specific height? Every 5th row as 80 for example? Thanks


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.