Calculating Page Count for a Range of Sections

by Allen Wyatt
(last updated December 18, 2021)


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:


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 Office 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. ...


Undesired Font in Form Fields

If you get unwanted formatting in your form fields, it could be because of the way you are formatting the line on which ...

Discover More

Preventing Changes to Multiple Selected Worksheets

It is common to select a group of worksheets and then print them. When done, any edits you make may affect the entire ...

Discover More

Pasting without Updating References

Do you need to paste formulas without updating the references in whatever you are pasting? You can accomplish this, ...

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)

Field Calculations in Locked Forms

When adding form fields to a document, you may want some of the fields to be automatically calculated from other fields. ...

Discover More

Inserting the Date Your Document was Last Saved

Word keeps track of the date each time you save your document. If you want to insert that "save date" in your document, ...

Discover More

Sequentially Numbering Elements in Your Document

One of the most powerful and useful fields provided by Word is the SEQ field. This tip describes how you can use the ...

Discover More

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


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 four minus 4?

2021-12-20 12:24:24


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.


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.