Showing a Dynamic Number Range in a Header

Written by Allen Wyatt (last updated March 1, 2022)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365


2

Mark uses a series of SEQ fields to number items on a page. In the header for the page, he would like to show the range of numbered items that appear on the page, such as 1234-1249. The SEQ fields work flawlessly, but Mark needs the header to update automatically to reflect the actual numbered sequence (first through last) on that page.

This is actually rather easy to do using the fields provided in Word. Fields allow you to create dynamic content, and in Mark's situation they can really shine. Before using the fields, however, there is a bit of "prep work" that needs to be done.

First, you'll need to make sure that the SEQ fields in your document are formatted with a style. Since the SEQ fields are (more than likely) not the only thing within the paragraph in which they are located, you should format them using a character style, not a paragraph style.

For instance, let's say that you create a style called MyNums that you intend to use for your SEQ fields. Apply it to all of them (just the SEQ fields, not anything else), and you will be ready to set up your headers.

Now, within your headers you are going to use the STYLEREF field to reference the first and last SEQ on each page. By default, the STYLEREF field displays the first content on a page that is formatted with a particular style. So, for instance, if you used this field you would get the first SEQ on the page that is formatted with the MyNums style:

{ STYLEREF "MyNums" }

Normally, people think of using the STYLEREF field to reference headings within a document, such as to create a running header that shows the first paragraph formatted with the Heading 1 style or the Heading 2 style on the page. This works fine, but you can also use STYLEREF to reference character styles, such as to reference the MyNums style.

If you want to reference the last occurrence of content formatted with the MyNums style, you would, instead, use the following field:

{ STYLEREF "MyNums" \l }

That's a lowercase "L" at the end of the field. This particular switch instructs Word to start its search for the MyNums style from the end of the page, going upwards. That way you get the last item formatted using MyNums.

So, to do what Mark wants done, you would use the following within the header for the document:

{ STYLEREF "MyNums" }-{ STYLEREF "MyNums" \l }

Remember that the {braces} are not actually typed into the heading; they are field braces and are inserted by pressing Ctrl+F9. Once the fields are inserted in the header, you can select them all and press Shift+F9 to collapse the fields and show the range of SEQ fields on the page.

You may notice that once you have the header set up, it may not appear to automatically update as you add new items to your pages. This is normal; the field codes are usually only updated when you go to print your document. Rest assured that they will reflect the correct range of items on the page when you actually do print.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (11218) 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

Determining the Least Common Multiple

Need to figure out the least common multiple of a range of values? It is a snap when you use the LCM function, described ...

Discover More

Deleting VBA Code in a Copied Worksheet

VBA makes it easy to copy a worksheet from the current workbook into a brand-new workbook. You may want to delete some ...

Discover More

Saving Your Work Automatically

Word can be configured to save your work periodically; on any time schedule you desire. This tip explains this feature ...

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)

Conditional Calculations in Word

Word allows you to insert simple formulas, using fields, in table cells. You can also create simple conditional ...

Discover More

Locating Locked Fields

A field can be locked or unlocked, and its condition controls whether it is updated automatically or not. If you want to ...

Discover More

Inserting the Document Creation Date

One of the pieces of information tracked by Word is when a document was first created. Here's how you can access that ...

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?

2018-03-26 08:23:54

Jennifer Thomas

Hugh, depending on the complexity of the Invoice code, you might be able to do that with page numbers; just type the letters (SC) before the field in the actual document and then use Format Number to make the page numbering start at the first numbering value (63969).

This would work especially well if it's a one-page invoice; otherwise you'd have to get a bit clever with your section breaks and header linking to get it to increment on the correct page (comment back with more details about the document structure if you need advice on that).

SEQ or LISTNUM fields would be the next solution to try, as those are more customizable, but I hope the above works for you.


2018-03-24 06:46:31

Hugh Gundersen

How about a field that automatically adds 1 to a number on the previous page, bit like a page number but like "Invoice Nr: SC63969" next page would be "Invoice Nr: SC63970" etc?


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.