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

Seeing All Open Workbook Names

Ever want to see a list of all the workbooks that are open? If you open more than nine, Excel only displays the first ...

Discover More

Closing All Open Workbooks

Excel provides a handy (but little-known) shortcut for closing all the workbooks you have open. This tip explains how ...

Discover More

Replacing a Dimmer Switch

Dimmer switches can be very helpful in creating a soothing atmosphere or an alert atmosphere, all at the twist of a knob. ...

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 WordTips (ribbon)

Getting Rid of Fields Inserted by Third-Party Programs

Third-party programs can be used to affect a document and change what is contained therein. Of course, getting rid of ...

Discover More

Inserting a Document's Location

Once you save a document on disk, it is stored in a particular folder (or location) on that disk. You may want that ...

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

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.