logo
search
Document Editing Problems

Find and Highlight Repeated 3-to-5-Word Phrases in Word

Huda QurayshiHuda Qurayshi Sep 30, 2026 868 views

Question details

The user wants to identify and highlight identical consecutive phrases of three to five words across a Word document using a macro.

How to Find and Highlight Repeated 3-to-5-Word Phrases in Word
Product
Microsoft Word
Device & OS
not provided
Scenario
Proofreading or editing a large document to locate and remove redundant text blocks.
Observed behavior
A prepared macro-enabled document and VBA script failed to highlight the duplicate phrases as expected.
Before you start

Before running any VBA macros to modify or highlight text, ensure you have saved a backup copy of your document, as macro operations cannot always be reversed using the standard Undo function.

Solution 1Recommended

Create and Run a Custom VBA Macro

Use a specialized VBA script that accurately compares word groupings while accounting for punctuation and capitalization to successfully highlight duplicates.

To find repeated phrases of unknown content, the standard Find and Replace tool is insufficient. A VBA macro is required to programmatically read the document word by word, group them into arrays of 3 to 5 words, and compare these arrays against the rest of the text.

If a previous macro failed, it was likely due to exact string mismatches caused by trailing spaces, punctuation marks, paragraph breaks, or case sensitivity.

1
Open the VBA Editor

Press Alt + F11 on your keyboard while your Word document is open to launch the Microsoft Visual Basic for Applications (VBA) editor.

2
Insert a New Module

In the VBA editor, click on 'Insert' in the top menu bar and select 'Module' to create a new blank script window.

3
Paste the Macro Code

Paste your customized VBA code into the module window. Ensure the code includes logic to strip punctuation (like commas and periods) and uses 'UCase' or 'LCase' for case-insensitive comparisons.

4
Run the Macro

Press F5 or click the green 'Run' button in the top toolbar to execute the script. The macro will scan the document and apply a highlight color to the matching consecutive phrases.

Create and Run a Custom VBA Macro
Cross-Paragraph Matches: Ensure your macro script is designed to ignore paragraph breaks if you want to find phrases that start at the end of one paragraph and finish at the beginning of the next.
Free Microsoft Office alternative

Edit and Proofread Documents Seamlessly with WPS Office

If you are struggling with complex VBA macros or need an easier way to edit documents, consider switching to WPS Office. It provides a lightweight, highly compatible alternative for everyday word processing and proofreading tasks without the steep learning curve.

  1. 1. Download and Install: Get WPS Office for free from the official website and install it on your device.
  2. 2. Open Your Document: Launch WPS Writer and open your existing Word (.docx) document seamlessly.
  3. 3. Utilize Smart Tools: Take advantage of the built-in Find and Replace and formatting tools to edit your text efficiently.
Fully compatible with Microsoft Word (.doc, .docx) formatsLightweight software with fast document loading and processingBuilt-in smart editing and proofreading featuresClean, tabbed interface to manage multiple documents effortlessly
microsoft office alternative - wps office

Frequently Asked Questions

Can I find repeated phrases using the standard Find tool without a macro?

The standard Find tool (Ctrl + F) requires you to know the exact phrase you are searching for beforehand. It cannot automatically scan for unknown repeating patterns; you must use a VBA macro or a third-party add-in for automated phrase extraction.

Why didn't my existing VBA macro highlight the duplicate phrases?

Your macro likely failed to normalize the text before comparing it. Hidden characters, punctuation marks, line breaks, or variations in capitalization can cause two visually identical phrases to be treated as completely different strings by the VBA script.

Does capitalization affect the macro's ability to find repeated phrases?

Yes. Unless the VBA script explicitly uses a command like 'Option Compare Text' or converts all strings to lowercase ('LCase') during the comparison process, it will treat 'The quick brown' and 'the quick brown' as two different phrases.