Calculating Page Count for a Range of Sections

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


1

Jessica has a document that has four sections, and she wants to use the format "Page X of Y" for page numbering. She needs to be able to control the "Y" so that it only includes the number of pages in sections 1, 2, and 3 (section 4 is an appendix). Jessica knows she could insert the "Y" manually without using field codes, but the document is one that gets amended from time to time by more than one person and she wants to be sure it will update automatically.

When you insert a "Page X of Y" style of page number, Word is actually using the following text and fields:

Page { PAGE } of { NUMPAGES }

The PAGE field returns the current page number and NUMPAGES returns the number of pages in the entire document. If you want to have the "Y" portion be just the number of pages in the current section, then you can simply change the text and fields to this:

Page { PAGE } of { SECTIONPAGES }

Now the "Y" value will be the result of the SECTIONPAGES field, which is the number of pages in the current section.

If you want the number of pages in the first sections of a document, as a total, then you need to get a bit trickier with your field codes. For instance, in Jessica's case, she may want the "Y" value to be the total of the pages in sections 1, 2, and 3 of her document. Assuming that the page numbering is contiguous for these sections, the easiest way to do this is to define a bookmark on the last page of section 3. For instance, let's say that you name the bookmark something like Sec3End. Then, you can change your "Page X of Y" text and fields to the following:

Page { PAGE } of { PAGEREF Sec3End }

The PAGEREF field, in this case, returns the page number on which the Sec3End bookmark occurs. Since you placed it on the last page of section 3, your "Y" value is now the total number of pages in sections 1, 2, and 3.

If you wanted, instead, to have the "Y" value be the number of pages in a contiguous range of sections that didn't begin with section 1, then your fields need to be a bit more complex. For instance, in Jessica's case, she might want the "Y" value to reflect just the page count in sections 2 and 3. (Why this would be desired is beyond me, but calculating the total pages in the two sections is possible.) In this case, you need a bookmark on the first page of section 2 (let's call it Sec2Start) and the bookmark on the last page of section 3 (which we'll still call Sec3End). You can change your "Page X of Y" text and fields to the following:

Page { PAGE } of { = { PAGEREF Sec3End } - { PAGEREF Sec2Start } + 1 }

All you've done in this instance is to create a compound formula that returns the page numbers for the end of section 3, subtracts the page number for the start of section 2, and then adds 1 to the result. If you need to modify the "X" value in some way, you can do so by concocting a formula based on whatever mixture of PAGE and PAGEREF fields is appropriate for your needs.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12697) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365.

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

Word Features, by Program Version

When did Word add each new feature to the program? The answer isn't as clear-cut as you might think it is. This tip ...

Discover More

Page Layout Zoom Settings

The zoom setting at which you view a document can sometimes be saved with a document. This tip explains how the zoom ...

Discover More

Unwanted Weekend Dates in Chart

If you chart data that includes dates along one of the axes, you might be surprised to find out that the chart includes ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

More WordTips (ribbon)

Cross-Reference Removes Superscript Formatting

When you add a cross-reference to your document, it provides a way to dynamically reference text in another location, ...

Discover More

Compound Page Numbering

Simple page numbering is easy to add to your documents. More complex numbering (such as two numbering schemes in the same ...

Discover More

Setting Up an Array with Fields

One of the more esoteric ways to display data is with an "array," which is like a miniature inline table. This tip ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, 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 2 + 8?

2021-12-20 12:24:24

Victor

A real world situation in which you might want the page count of a range of sections is when you are using sections both for document structure (e.g., sections 2, 3 and 4 are "chapter 2") and document formatting (e.g., in the prior example, "chapter 2" comprises 3 sections because the middle section is oriented landscape).


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, 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.