Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, and 2013. 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: Understanding Pattern Matching.

Understanding Pattern Matching

by Allen Wyatt
(last updated March 10, 2020)


The Find and Replace feature built into Word includes two completely different search engines. In the normal search engine you search for simple items, such as text or special characters. Tips related to this type of searching have been presented in other issues of WordTips.

The second search engine is the more powerful, however. It uses a search method known as pattern matching. When you use pattern matching you can search for very complex and very subtle character sequences in your document. Unfortunately, learning the pattern matching capabilities of Word can sometimes be frustrating.

How you switch between the two different search engines depends on the version of Word you are using. In most versions of Word you should pull up either the Find or Replace tabs of the Find and Replace dialog box and click on the More button. In the expanded area of the dialog box, make sure the Use Wildcards checkbox is selected. This causes Word to interpret what is in the Find What and Replace With boxes entirely differently than if the checkbox is not selected.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (263) applies to Microsoft Word 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Word here: Understanding Pattern Matching.

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


Finding the Address of the Lowest Value in a Range

Uncovering the lowest value in a range is relatively easy; you can just use the MIN worksheet function. Discovering the ...

Discover More

Understanding Date and Time Formatting Codes

Want to apply a custom format to your dates and times? To do it effectively you need to understand the custom formatting ...

Discover More

Exporting a Graphics Group

Need to export a graphics group from a chart so that you can use the group in a different program? It's not as easy as ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (ribbon)

Replacing Two Tabs with a Space in Limited Situations

The Find and Replace feature of Word is very powerful, allowing you to finely target exactly what you want to search. ...

Discover More

Formatting Partial Results of a Search

The Find and Replace capabilities of Word are, simply, quite astounding. This is particularly true when using wildcard ...

Discover More

Ordering Search and Replace

The wildcard searching available in Word is very powerful. Here's how you can use ordering in your search efforts to make ...

Discover More

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


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 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 one more than 9?

2019-09-21 03:02:48

Ken Endacott

Rich, the macro pauses and gives a message each time a zero result field is found. It might be quicker if the macro highlighted all the zero result fields in one pass then you can go over them individually. To do this, replace the line:

MsgBox "The field " & aField.Code & " returns zero"


aRange.HighlightColorIndex = wdPink

2019-09-20 10:40:24


Ken, thanks a LOT! I'll give this a try. It's sure to save me plenty of anguish.

2019-09-14 04:34:02

Ken Endacott


Here is a macro that will do what you want.

Sub findFields()
Dim aField As Field
Dim aRange As Range
Dim k As Long
Application.Browser.Target = wdBrowseField
Set aRange = Selection.Range
k = aRange.Fields.Count
If k > 0 Then
Set aField = aRange.Fields(1)
If Trim(aField.Result.Text) = "0" Then _
MsgBox "The field " & aField.Code & " returns zero"
MsgBox "No more fields found "
End If
Selection.Collapse Direction:=wdCollapseEnd
Loop Until k = 0
End Sub

2019-09-13 11:30:38


I have had this problem for years and I can't seem to find a satisfactory answer for it:
I use LOTS of field codes in my documents. These documents then get forwarded to lots of people for review - people who have no idea what a field code is and have no interest in learning what it is. Naturally, when the document returns back to me there are likely going to be a lot of broken field codes, "ERROR! Reference source not found" Those are easy to deal with. I just search for "Error!" and fix them.
HOWEVER... sometimes my x-refs don't error, but they will display "0" instead. Searching for "0" is inefficient in a document full of numbers. I want to search for "0" in a FIELD, but there doesn't seem to be anyway to do that. Evidently, I can search for a field, but I need to know the name of the field and I don't think I can search for a NAMED FIELD OF A PARTICULAR VALUE ('0')

Any insight on why this happens ("0" vs "Error!") and how to fix it without slogging through page by page? Thanks.

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

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.