Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Setting Consistent Column Widths in Multiple Tables.

Setting Consistent Column Widths in Multiple Tables

by Allen Wyatt
(last updated May 12, 2012)

2

Sheryl routinely creates documents that have many, many tables in them. Each of the tables is consistent in that they have the same general layout. (Each contains the same number of columns with each column containing the same type of information.) Sheryl is looking for a way to make sure that the widths of the columns in all the tables are consistent.

The solution depends on when you need to create the tables. If the document is a new one, then creating the tables in a consistent manner is rather easy. As has been described in other WordTips (and which I won't go into here), you can save your standard tables in an AutoText entry or create a table style that defines how you want your table to appear. When needed, you simply insert the AutoText entry or apply the style, and the table appears as you desire.

The solution is a bit more involved if your document is already created and you simply want to apply consistency to the tables that exist within the document. In that case, the solution is to use a macro to change the widths of columns.

It is possible to create a macro that will quickly step through each table in a document and make each column in the table the same width, in this manner:

Sub SetColumnWidths1()
    Dim t As Table
    For Each t In ActiveDocument.Tables
        t.Columns.Width = InchesToPoints(2)
    Next t
End Sub

Chances are good, however, that you don't want each column to be 2 inches wide. You probably want each column to be a specific width, different from the other columns. The following iteration of the macro handles that likelihood:

Sub SetColumnWidths2()
    Dim t As Table
    For Each t In ActiveDocument.Tables
        t.Columns(1).Width = InchesToPoints(2)
        t.Columns(2).Width = InchesToPoints(2.5)
        t.Columns(3).Width = InchesToPoints(3)
    Next t
End Sub

The drawback to such a macro is that you need to specify, in the coding, the width of each column. Also, if you have an anomalous table in your document (it doesn't have the same number of columns as all your other tables), then the macro blithely tries to set the width of the columns.

A better approach, then, may be to have a "model" table in your document and then set all your other tables so that they use the same column widths as that table. An easy approach is to manually format the column widths of the first table in the document, then have the macro examine that table and use it as the pattern for the rest of the table columns.

Sub SetColumnWidths3()
    Dim t As Table
    Dim c As Column
    Dim ccnt As Integer
    Dim w() As Single
    Dim J As Integer
    Dim K As Integer

    Set t = ActiveDocument.Tables(1)
    ccnt = t.Columns.Count
    ReDim w(ccnt)
    J = 0
    For Each c In t.Columns
        J = J + 1
        w(J) = c.Width
    Next c

    For J = 2 To ActiveDocument.Tables.Count
        Set t = ActiveDocument.Tables(J)
        If t.Columns.Count = ccnt Then
            For K = 1 to ccnt
                t.Columns(K).Width = w(K)
            Next K
        Endif
    Next J
End Sub

This macro examines the number of columns in the first table (assigning the value to the ccnt variable) and then looks at the width of each of those columns (assigning the values to the w array). It then steps through the rest of the tables in the document, and if the number of columns in the table matches the number in the ccnt variable, it sets the width of each column to the widths stored in the w array. The result is that each table in the document (well, at least those that have the same number of columns as the first table) has the same column widths.

There is one potential gotcha here: If the tables in your document use merged cells in any way, it could mess up the results you get. In that instance, you'll want to save your document before running the macro. That way you can check the results, visually, and then revert to the saved document, if necessary.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (11692) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Setting Consistent Column Widths in Multiple Tables.

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

Colorizing Charts

Need to change the color of different parts of your chart? It's easy to do when you apply the technique described in this ...

Discover More

Fitting Text Into Cells

Need a way to make sure your text fits within the space available in a table cell? Word has a handy setting that will adjust ...

Discover More

Skipping Numbering

Got a numbered list, but you want to add other types of non-numbered paragraphs in the middle of the list? It's easy to do if ...

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 (MENU)

Hiding Table Gridlines, by Default

The edges to table cells are shown two ways in Word: gridlines and borders. Table gridlines are only seen in Word; they do ...

Discover More

Squaring Table Cells

Inserting a table is fast and easy in Word. You may want to make sure that the cells in the table are as square as possible. ...

Discover More

Formatting an ASCII Table with Spaces

When you get a text file from a program other than Word, tabular information may be formatted with nothing but spaces in ...

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 for this tip:

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. 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 9 - 7?

2015-08-11 22:33:10

Dana Cole

If your tables all have the same number of columns, there is a much simpler way to do this, I believe:

1. Open a new document.
2. Format a one-row table with column widths as you want it to appear.
3. Place the cursor in the first cell of the table.
4. Go to the document with your existing table.
5. Select all material within that table, excluding any headers or anything outside the table at its end (these are crucial - only select material WITHIN the table and do NOT select any repeating headers).
6. Go back to your new document.
7. Paste the material from the table into the new document.
8. Insert a new table row beneath the table in the new document. Place the cursor in the first cell of that row.
9. Repeat steps 3-8 for all tables you want to appear in the new format.

This prevents using a macro, which can cause difficulties if you are trying to share the document with others.

Thanks for all your tips. I'm very experienced with Word, so have no need to take the course, but you have helped me a lot.


2013-09-24 01:34:16

Ritish R

Hi,
I have a huge financial file for formatting and this has different column width through out the file for eg.
3 column width table consists of :
70 % + 15% + 15% respectively
4 column width:
55% + 15% + 15% + 15%
5 column width:
40% + 15% + 15% + 15% +15%
6 column width:
40% + 12% +12% +12% +12% +12% and so on and I need upto around 9 colcumn width where the 1st column least size can be 28% and cannot go less than that but the next column width can vary.

The width need to be measured in percentage because when uploaded on webpage as HTML file the table should expand accordingly


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon 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.

Links and Sharing