Dynamically Setting a Print Area

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


1

Travis has a cell that, through a series of formulas, contains the upper-left corner of a 5 column by 20 row area that needs to be printed. For instance, if the cell contains $F$15, then the print area would be F15:J34, but if it contained $D$45, then the print area would be D45:H64. Travis wonders if it is possible to dynamically set the print area based on the contents of the cell, without using a macro.

Yes, there is a way you can set a dynamic print area without using a macro. Let's assume for the purposes of this tip that the calculated cell address is in A1. In preparation, you need to set up a print area:

  1. Select a random cell or range of cells; it doesn't really matter at this point.
  2. Display the Page Layout tab of the ribbon.
  3. Click the Print Area tool. Excel displays two options.
  4. Choose the Set Print Area option.

When you set a print area in this manner, Excel creates a named range called Print_Area. Whatever range it refers to is what will be printed when you choose to print. Since it is a named range, you can modify it in the Name Manager. Follow these steps to make the print area dynamic:

  1. Press Ctrl+F3. Excel displays the Name Manger.
  2. If there is more than one named range, select the Print_Area name.
  3. Click the Edit button. Excel displays the Edit Name dialog box. (See Figure 1.)
  4. Figure 1. The Edit Name dialog box.

  5. In the Refers To box, at the bottom of the dialog box, replace whatever is there with the following formula. (If the name of the worksheet is different from what is shown in this formula, make the necessary change to reflect reality.)
  6. =OFFSET(INDIRECT(Sheet1!$A$1),,,20,5)
    
  7. Click OK to close the Edit Name dialog box.
  8. Click OK again to close the Name Manager.

That's it. Your print area is now dynamic, dependent on the address stored in cell A1.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13946) 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

Controlling the Format of Cross-References

When you use fields to add cross-references to tables or figures, Word normally takes care of formatting the words used ...

Discover More

Inserting Cells in a Table

You can enlarge a table by adding cells where they are needed. Just pick where you want the cells inserted, then use the ...

Discover More

Summing Filled Cells

If you have a column of data that contains color-coded cells, you may want a way to sum values in the column based on 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 (ribbon)

Locking the Print Area

Excel allows you to specify an area of your worksheet that should be printed. Here's how to "lock" that area so it cannot ...

Discover More

Printing Multiple Selections

Need to print several portions of a worksheet all on a single piece of paper? Here's an easy way you can get what you ...

Discover More

Setting Print Ranges for Multiple Worksheets

Need the same print range set for different worksheets in the same workbook? It can't be done in one step manually, but ...

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 five less than 6?

2024-12-21 13:22:01

Tomek

I like the solution presented in this tip (I suggested this approach in my reply to help-wanted, but I probably wasn’t the only one). It is relatively simple, does what Travis wanted, and does not “contaminate” the spreadsheet with helper cells. What Allen did not mention was that the address of the cell A1 in the formula must be entered as an absolute address, i.e., Sheet1! $A$1; if it is entered as the relative address the Print_Area is not set properly, and the approach does not work (why? – I don’t know).

I also suggested another approach, that may not be as elegant, but potentially may have additional advantages. The steps are as follows:
1. Select a 20-rows by 5-columns range somewhere on the sheet, where it would not interfere with your data. Set the Print Area to that range.
2. In the top left corner of that print area enter =OFFSET(INDIRECT($A$1),0,0,20,5). This formula will spill and populate Print_Area with a copy of what you want to print, and when you print the sheet, it is what will be printed. As in the tip, I assume that the calculated cell address is in A1.
3. If using an older version of Excel that does not automatically spill into Array, you will need to enter the above formula as an Array Formula (Ctrl+Shift+<ENTER>) covering the whole Print_Area range.

The benefit of this approach is that you can format the data that is in the Print_Area any way you want, independently of the format of original data. Additionally, you can add rows above to add column labels and possibly the title, and add a column to the left for row labels. Those do not have to be static but can also depend on the content of A1. If you add rows and columns, obviously you will need to adjust the print area to include them as well.

There is one disadvantage of this approach: if any of the original cells are blank, they will show in the print area as zeros, probably not what you would want. It can be easily overcome by slight modification of the formula entered in step 2 as follows:
=IF(OFFSET(INDIRECT($A$1),0,0,20,5)="","",OFFSET(INDIRECT($A$1),0,0,20,5))
See screenshots of my test workbook (see Figure 1 below) (see Figure 2 below)

Figure 1. Source Data

Figure 2. Formatted Print Area


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.