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: Highlight Words from a Word List.

Highlight Words from a Word List

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


Paul has a document that he needs to check against a word list contained in another document. If the document being checked contains one of the words in the list, then the word in the document (not in the word list) needs to be highlighted. The word list is large, on the order of 20,000 words, and Paul is wondering what the best way to do this is.

The easiest way to do this is to write your own macro that will do the comparisons for you. Start by putting the words you want find in their own document. Put one word (or phrase) per paragraph (just press Enter after each word or phrase), and make sure the document is named "checklist.docx." With the document in the C: drive, the following macro can be used:

Sub CompareWordList()
    Dim sCheckDoc As String
    Dim docRef As Document
    Dim docCurrent As Document
    Dim p As Paragraph
    Dim sLookWord As String

    sCheckDoc = "c:\checklist.docx"

    If Dir(sCheckDoc) = "" Then
        MsgBox "Checklist file not found."
        Exit Sub
    End If

    Set docCurrent = ActiveDocument
    Set docRef = Documents.Open(sCheckDoc)
    Options.DefaultHighlightColorIndex = wdYellow

    With docCurrent.Content.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Forward = True
        .Format = True
        .MatchWholeWord = True
        .MatchCase = True
        .MatchWildcards = False
        .Wrap = wdFindContinue
        .Replacement.Highlight = True
        .Replacement.Text = "^&"

        For Each p In docRef.Paragraphs
            sLookWord = Trim(Replace(p.Range.Text, vbCr, ""))
            If Len(sLookWord) > 0 Then
                .Text = sLookWord
                .Execute Replace:=wdReplaceAll
            End If
        Next p
    End With

    docRef.Close False
End Sub

All you need to do is have the document open that you want checked, and then run the macro. If the document containing the words to check is named differently or in a different location, just change the line that sets sCheckDoc so that it has a different full path name for the document.

Basically, the macro grabs each word or phrase from checklist.docx and then does a Find and Replace operation using that word in the document. If the word is found, then it is highlighted in yellow. The macro also pays attention to case in what it finds. Thus, if your search word is "luckily," then it will only highlight the word if it is lowercase, meaning if a sentence begins with "Luckily," then it would not be highlighted.

You can put as many words in the checklist.docx document as you want, but understand that a Find and Replace is done for each of them. That means that if it contains a lot of words and the document you are searching is large, the macro can take quite a while to run. Paul said that he had 20,000 words that needed to be checked for, which means that the macro would do 20,000 Find and Replace operations. That may be enough time to take a lunch break while the macro is running.

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 (1173) 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: Highlight Words from a Word List.

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

Counting Groupings Below a Threshold

When analyzing data, you may need to distill groupings from that data. This tip examines how you can use formulas and ...

Discover More

Editing a Scenario

Once a scenario is defined and saved, you can later revisit the values you created for the scenario and modify them. ...

Discover More

Filtering for Purchases within a Given Month

Filtering is a great tool when dealing with large data sets. Knowing how to apply a filter, though, can be a bit tricky ...

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 2019. Spend more time working and less time trying to figure it all out! Check out Word 2019 For Dummies today!

More WordTips (ribbon)

Getting User Input in a Dialog Box

Want to grab some interactive input from a user in your macro? The best way to do that is with the InputBox function, ...

Discover More

Renaming a Macro

Want to give your macros a different name than they currently use? It's easy to do using the VBA Editor as described here.

Discover More

Recording a Macro

One of the most common ways of creating macros is to use Word's macro recorder. This tip shows how easy it is to use 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}] (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 + 1?

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.