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

Default Picture Settings

Place enough pictures, and sooner or later you start wondering if there is a way to set up some default settings for ...

Discover More

Preventing Changes to Styles in Documents

Have you ever created a template only to have the styles within it changed as they were used within a document? Here are ...

Discover More

Working with Elapsed Time

Work with times in a worksheet and you will eventually want to start working with elapsed times. Here's an explanation of ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (ribbon)

Word and Character Count Information

Using fields you can easily insert both the word and character counts for a document into the document itself. Here's how ...

Discover More

Formatting a SEQ Field Number

The SEQ field is a great way to insert a sequence of numbers within your document. If you want those numbers to be ...

Discover More

Inserting the Date Your Document Was Last Printed

Word keeps track of each time you print your document, and you can automatically insert the last printing date anywhere ...

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 1 + 1?

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.