Increasing Row Height for Printing

Written by Allen Wyatt (last updated April 15, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


1

Jeaux works with a lot of long worksheets that contain data she may need to print. Once printed, she then writes in the space next to the column of data. All rows are auto sized to fit contents, therefore they vary in height. Jeaux is looking for a macro that will take the selected rows and incrementally increase them, say by a given percentage. (Since they are different heights, she cannot just set them all to the same height.) This way, she can make the rows large enough for handwriting, but still be able to see all of the data. It would also be nice to have a way to set the rows' height back to what they were before she printed.

This task is very easy to accomplish with a macro. All you need to do is step through the selected rows and adjust the RowHeight property, as is done in this macro:

Sub ExpandSelectedRows()
    Dim rRow As Range
    Dim dEnlarge As Double

    dEnlarge = 1.25
    For Each rRow In Selection.Rows
        rRow.RowHeight = rRow.RowHeight * dEnlarge
    Next
End Sub

In this case, the dEnlarge variable contains 1.25, which means that the formula in the For ... Next loop will increase the row height by 25 percent. The value of this variable can be changed to reflect the percentage you want to use, or you could modify the macro to ask the user for a percentage:

Sub ExpandSelectedRows()
    Dim rRow As Range
    Dim dEnlarge As Double
    Dim sTemp As String

    sTemp = InputBox("Increase by what percent?")
    dEnlarge = Val(sTemp)
    If dEnlarge > 1 Then dEnlarge = dEnlarge / 100
    If dEnlarge < 1 Then dEnlarge = dEnlarge + 1

    If dEnlarge > 0 Then
        For Each rRow In Selection.Rows
            rRow.RowHeight = rRow.RowHeight * dEnlarge
        Next
    End If
End Sub

If you later want to get the rows back to their original height, the following single-line macro will do the job:

Sub AutfitRows()
  Cells.EntireRow.AutoFit
End Sub

This macro works because the rows in your worksheet originally were "auto sized to fit contents." While a macro could have been written to reverse the enlarging steps (dividing by dEnlarge instead of multiplying), it would only work reliably if the ExpandSelectedRows macro wasn't run multiple times.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (21) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

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

Changing Error Checking Rules

Excel can check the data and formulas in your worksheet to see if it detects any errors. The rules used for this checking ...

Discover More

Differences between SEQ and LISTNUM Fields

Word provides several different fields you can use for custom numbering in a document. Two of the most commonly used are ...

Discover More

Automatically Creating Charts for Individual Rows in a Data Table

If you have a lot of records in a data table, you may want to create individual charts based on the information in those ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

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

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

Changing Default Row Height

Changing the default row height used for a worksheet is relatively easy, as long as you don't mind the row height never ...

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 8 - 5?

2023-04-15 12:29:33

J. Woolley

My Excel Toolbox includes the AdjustRowHeights macro to adjust the height of selected rows by a fixed increment or a proportional multiplier. The AdjustColumnWidths macro will adjust the width of selected columns in the same way. Both macros support Undo (Ctrl+Z).
See https://sites.google.com/view/MyExcelToolbox/


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.