Displaying a Column Number

by Allen Wyatt
(last updated January 6, 2017)

3

Deena has a document that is formatted to use three columns. She would like a way to display and print, automatically, a column number at the top of each column. Thus, the columns on page 1 would be numbered 1 through 3, those on page 2 would be 4 through 6, etc.

There is no way to do this automatically, but a workaround is to create a macro that will print the document with column numbers in the page header. All you need to do is make sure that the header has tab stops set to match where you want the column numbers to appear.

Sub ColumnHeaders()
    Dim p As Long
    Dim tp As Long
    Dim c As Integer
    Dim tc As Integer
    Dim h As String
    Dim ch As String

    ' Get total pages
    tp = ActiveDocument.Content.ComputeStatistics(wdStatisticPages)
    ' Get number of columns
    tc = ActiveDocument.Sections(1).PageSetup.TextColumns.Count
    ' Save current header
    ch = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text

    For p = 1 To tp
        h = ""
        For c = 1 To tc
            h = h & Trim(Str(p + (c - 1) + (2 * p - 2))) & vbTab
        Next c
        h = Left(h, Len(h) - 1)
        ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = h
        ActiveDocument.PrintOut Range:=wdPrintFromTo, _
          From:=Trim(Str(p)), To:=Trim(Str(p))
    Next p
    
    If Len(ch) > 1 Then
        ' Restore previous header
        ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = ch
    Else
        ' There is no previous header
        ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Delete
    End If
End Sub

The macro actually prints out each page of the document individually. It assumes there is only a single section in the document. The number of columns for that single section is determined, and then this count used in putting together the header for each page. The header consists of the column numbers separated by tabs. The header is constructed for each page, and then each page is printed.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12826) applies to Microsoft Word 2007, 2010, and 2013.

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

Find and Replace in Text Boxes

Find and Replace can work great, but not necessarily for text within text boxes. This tip discusses all the ins and outs of ...

Discover More

Sharing AutoText Entries in a Network

Creating AutoText entries can be a great way to improve your productivity with Word. At some point you may want to share ...

Discover More

Specifying Date Formats in Headers

Don't like the default date format used by Excel when you place the date in a header or footer? You can use a macro to get ...

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)

Making Columns the Same Length

Balancing the length of each column in a multi-column page layout can be a challenge. Here's a quick way to get Word to do ...

Discover More

Changing the Number of Columns

If you need to change the number of columns used in a portion of your document, it's easy to do when you use the Columns ...

Discover More

Changing the Number of Columns in the Middle of a Document

Need to have multiple columns in a page layout that normally consists of a single column? You can change the column layout by ...

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 8Mpixels. 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 three more than 5?

2017-01-06 11:44:35

Aprile Morgan

If all the document contained were the columns, couldn't she put in a heading with styles to auto number? She would just have to line them up so they match three columns. Not sure this would work but worth a try.


2013-12-09 08:56:50

Jim Swindle

Keith - Think of a macro as a script that automates something you want to do over and over. For an overview, in Word click the ? button. Then type
record macro
and click Search. You'll find information about recording or running or writing a macro.


2013-12-08 15:08:54

Keith

I do not understand the word "macro" so could not make use of this tip. I would like to know how many others are in the same boat,


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.