Finding Tables that are Too Narrow or Too Wide

Written by Allen Wyatt (last updated August 8, 2026)

2

Orson has a document that is about 300 pages long and contains more than a hundred tables. The text area within the document is 6.5 inches. Orson needs a way to easily find any table that is less than 6.25 inches wide or more than 6.5 inches wide. This doesn't seem to be something he can do with Find and Replace, so he wonders if he will need a macro.

The short answer is yes, a macro is required to perform this type of analysis. Fortunately, the macro doesn't need to be very complex. It simply needs to step through each table, calculate the table width, and then make a determination of what to do if the width is outside of Orson's target width. The following macro performs exactly those steps:

Sub AnalyzeTableWidths()
    Dim tbl As Table
    Dim tblWidth As Double
    Dim tblCount As Long
    Dim sMsg As String
    Dim pg As Long
    Dim docReport As Document

    sMsg = ""
    tblCount = 0
    For Each tbl In ActiveDocument.Tables
        tblCount = tblCount + 1
        tblWidth = tbl.PreferredWidth / 72

        If tblWidth < 6.25 Or tblWidth > 6.5 Then
            pg = tbl.Range.Information(wdActiveEndPageNumber)
            If sMsg = "" Then
                sMsg = "Tables out of range (< 6.25"" or > 6.5""):"
                sMsg = sMsg & vbCrLf & vbCrLf
            End If
            sMsg = sMsg & "¥ Table #" & tblCount & " on page " & pg & _
            " (Width: " & Format(tblWidth, "0.00") & " in.)" & vbCrLf
        End If
    Next

    ' Show the results
    If sMsg = "" Then
        sMsg = "All tables are within the allowed width (6.25"" - 6.5"")."
    Else
        Set docReport = Documents.Add
        docReport.Content.Text = sMsg
        sMsg = "Scan complete! A summary report has been created "
        sMsg = sMsg & "in a new document."
    End If
    MsgBox sMsg, vbInformation, "Done"
End Sub

Note that the macro puts together a report in the sMsg string as it steps through each table. The report includes not only the width of the table, but also the page on which the table is located. When complete, if there is something in the report, then a new document is created and the report is placed there. If no tables were found outside the target width, then a message box to that effect is displayed.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13992) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, 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

Converting Field Results to Text

Fields are meant to be dynamic, providing a result based on conditions at the time they are updated. You may want to ...

Discover More

Quickly Updating Values

You can easily adjust the values in a range of cells by a certain amount. The key is to modify how you use the pasting ...

Discover More

Printing a Key Assignment List

When you create custom shortcut keys in Word, you may (at some point) want to get a printout of what those key ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 365 applications with VBA programming. Written in clear terms and understandable language, the book includes systematic tutorials and contains both intermediate and advanced content for experienced VB developers. Designed to be comprehensive, the book addresses not just one Office application, but the entire Office suite. Check out Mastering VBA for Microsoft Office 365 today!

More WordTips (ribbon)

Converting Tables to Text

Need to convert all the tables in your document into plain text? This tip provides a macro that can make quick work of a ...

Discover More

Summing a Table Column

Need to add a sum to a column of figures in a table? Word makes it relatively easy to provide the sum you need.

Discover More

Hiding Table Rows on a Printout

When you work with tables in your document, you may want to hide some of rows in those tables so that they don't print ...

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 - 0?

2026-08-09 09:37:16

beepee

Addendum to my comment 2026-08-08 11:51:35
I am still 'playing' trying to resolve this.
Having ventured into Copilot for some help I came up with the following...

The code snippet below, gets me the right results by adding column widths together to arrive at the table width.

For LoopCount = 1 To tblCount
Set tbl = ActiveDocument.Tables(LoopCount)
TableWidth = 0
For Each col In tbl.Columns
TableWidth = TableWidth + col.Width
Next col

With the original macro:
Hovering over - tbl.PreferredWidth – I get – TblPreferredWidth = 9999999 – I assume this is a default and maybe I need a - Set - statement somewhere, and that is what is scuppering the .PreferredWidth value?


2026-08-08 11:51:35

beepee

This could be really handy but...
I am using Windows 11 Office (Word) 2021
and with differnt sized tables in a document I get the following report:
¥ Table #1 on page 7 (Width: 138888.88 in.)
¥ Table #2 on page 37 (Width: 138888.88 in.)
¥ Table #3 on page 37 (Width: 138888.88 in.)
¥ Table #4 on page 57 (Width: 138888.88 in.)
¥ Table #5 on page 59 (Width: 138888.88 in.)

Obviously very wrong - I thought maybe my dimension settings in cm may be a problem. I reset this to inches with the same result. - even after a Close and re Open operation!
Any help please!


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.