Showing a Dynamic Number Range in a Header

by Allen Wyatt
(last updated March 24, 2018)

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, and 2016.

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

Running Macros from Macros

Need to run one macro from within another macro? You can easily do it by using the Run method of the Application object, ...

Discover More

Putting an X in a Clicked Cell

Need to click on a cell and have it replaced with an "X"? Macros make it easy to do, as illustrated in this tip.

Discover More

Understanding Monospace Fonts

Information in a worksheet needs to be displayed using fonts. If you understand the two different types of fonts ...

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (ribbon)

Moving Footnote References Using Find and Replace

When you are editing a document, you may need to modify where the author placed footnotes relative to surrounding ...

Discover More

Maintaining Fields in a Merged Document

When merging documents, you may want to include some fields in the merged documents. For some fields this is impossible, ...

Discover More

Displaying Fields

Fields (sometimes called field codes) allow you to insert dynamic information in your documents. If you want to see the ...

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}] 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 3 + 8?

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.

Newest Tips
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.