Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Finding Long Sentences.

Finding Long Sentences

Written by Allen Wyatt (last updated July 12, 2025)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365


Bruce is looking for some way to have Word automatically mark long sentences in a document. For instance, he may want to have those sentences with more than 20 words marked in some color so that they are easily located.

Fortunately, Word maintains a Sentences collection, accessible through VBA, that consists of each sentence in a document. You can examine each item in this collection (each individual sentence) to determine if it is longer than your desired length. The following macro provides an example of how this is done.

Sub MarkLong1()
    Dim iMyCount As Integer
    Dim iWords As Integer

    If Not ActiveDocument.Saved Then
        ActiveDocument.Save
    End If

    iWords = 20   ' target word count

    iMyCount = 0 
    For Each MySent In ActiveDocument.Sentences
        If MySent.Words.Count > iWords Then 
            MySent.Font.Color = wdColorRed
            iMyCount = iMyCount + 1
        End If
    Next
    MsgBox iMyCount & " sentences longer than " & _
      iWords & " words."
End Sub

Notice that the macro starts by saving the document. This is done because long sentences are going to be formatted as red text, and saving makes sure you have a "pre-change" version saved. Each sentence is examined, and if it is longer than the desired length (defined by the variable iWords) then the sentence is changed to a red font color. This makes it easy to examine the document and discover which sentences exceed the length you specified.

There is a drawback to this macro, though: The .Count property for the Words collection counts punctuation as individual words. Thus, the sentence "Really, she asked." would have a count of 5 words, instead of the 3 expected, because there are two punctuation marks. If you don't want punctuation marks included in figuring out the sentence lengths, then the macro needs to be lengthened just a bit:

Sub MarkLong2()
    Dim iMyCount As Integer
    Dim iWords As Integer
    Dim MySent As Range
    Dim iWordCount As Integer
    Dim sPunc As String
    Dim J As Integer

    iWords = 20   ' target word count
    sPunc = ".,?!;:-"   ' don't count these as words

    iMyCount = 0
    For Each MySent In ActiveDocument.Sentences
        If MySent.Words.Count > iWords Then
            iWordCount = 0
            For J = 1 To MySent.Words.Count
                If InStr(sPunc, Trim(MySent.Words(J))) = 0 Then
                    iWordCount = iWordCount + 1
                End If
            Next J
            If iWordCount > iWords Then
                MySent.Font.Color = wdColorRed
                iMyCount = iMyCount + 1
            End If
        End If
    Next MySent
    MsgBox iMyCount & " sentences longer than " & _
      iWords & " words."
End Sub

In this version, if the .Count property is greater than iWords, then a trimmed version of each word in the sentence is compared against a string of punctuation characters (sPunc). Only if the word is not within the punctuation string is it counted. It is this secondary count (iWordCount) that is finally compared against iWords and, if it is greater, the sentence is formatted as red.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (11909) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365. You can find a version of this tip for the older menu interface of Word here: Finding Long Sentences.

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

Functions that Can Access Closed Workbooks

When creating a workbook, you can include formulas that reference data stored in other workbooks. Some functions will ...

Discover More

Getting a Count of Unique Names

When you have a column full of names, you may want to get a count of how many of those names are unique. You can make ...

Discover More

Rounding Time

Need to round the time in a cell to a certain value? There are a couple of ways you can do this with a formula.

Discover More

Do More in Less Time! An easy-to-understand guide to the more advanced features available in the Microsoft 365 version of Word. Enhance the quality of your documents and boost productivity in any field with this in-depth resource. Complete your Word-related tasks more efficiently as you unlock lesser-known tools and learn to quickly access the features you need. Check out Microsoft 365 Word For Professionals For Dummies today!

More WordTips (ribbon)

Removing Tabs Used to Indent a Paragraph

You get a document from a colleague and you notice that each paragraph starts with a tab character. Here are a couple of ...

Discover More

Breaking Into Sentences

Macros allow you to easily extend what you can do with Word. If you have a common editing task, that task can often be ...

Discover More

Using the Object Browser

Efficiently navigating through a document, particularly as it gets longer, can be a perpetual challenge. One tool you can ...

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

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


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.