Specifying the Y Value in X of Y Page Numbering

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


1

Dawn has workbooks with multiple tabs (worksheets) in them. She uses "Page of Pages" (X of Y) numbering in the page footers. She notes that she used to be able to print entire workbooks at once and have the numbering come out correctly, with the Y value being the number of pages in each worksheet. Since upgrading to Excel 2016, the Y value on her printouts is always the total number of pages in the workbook, not the number of pages in each worksheet. She wonders if there is a setting in Excel that determines how the Y value is counted (per worksheet or per workbook).

There is no setting that we've been able to locate. Instead, it appears that Excel determines both the X and Y values based on the current print job, not on worksheets or the entire workbook. In other words, if your workbook contains three worksheets, and you print all three, the X and Y values will be different than if you choose to print only the second or the second and third worksheets.

The solution to this is to use a small, simple macro that steps through all the worksheets in a workbook and prints the worksheets individually. As far as Excel is concerned, then, you are performing multiple print jobs, thus the Y value will get reset on a worksheet-by-worksheet basis. Here's the macro:

Sub PrintProperly()
    Dim sht As Worksheet
    For Each sht In ActiveWorkbook.Worksheets
        sht.PrintOut copies:=1
    Next sht
End Sub

Assign the macro to a shortcut key or to a button on the Quick Access Toolbar, and you'll be able to invoke it easier.

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 (12454) 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 the Default Drive

Do you have a macro that need to read and write files? If so, then there is a good chance you need to specify the default ...

Discover More

Creating a Shortcut for Pasting Values

Excel's Paste Special command is used quite a bit. If you want to create some shortcuts for the command, here's some ways ...

Discover More

Sorting while Ignoring Leading Characters

Want to ignore some characters at the beginning of each cell when sorting? The easiest way is to simply create other ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Putting a Different Date in a Header

Today's date is easy to add to a header, but what if you want to add a date that is adjusted in some manner? Adding ...

Discover More

Using X of Y in a Page Footer

If you want your printed worksheet to include page numbers, adding them is relatively easy. This tip shows two ways that ...

Discover More

Putting Cell Contents in Footers

Referencing information between cells in a worksheet is a piece of cake using some elemental formulas. You cannot, ...

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 two more than 7?

2023-04-22 20:57:36

Tomek

You just have to remember that certain print attributes are defined per each worksheet. This applies to headers and footers.
On a positive note, you can define headers and footers for several sheets at once, just make sure they are all selected before defining the header/footer. that way they will be consistent.


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.