Find and Highlight Repeated 3-to-5-Word Phrases in Word
Question details
The user wants to identify and highlight identical consecutive phrases of three to five words across a Word document using a macro.

- 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 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.
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.
Press Alt + F11 on your keyboard while your Word document is open to launch the Microsoft Visual Basic for Applications (VBA) editor.
In the VBA editor, click on 'Insert' in the top menu bar and select 'Module' to create a new blank script window.
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.
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.

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. Download and Install: Get WPS Office for free from the official website and install it on your device.
- 2. Open Your Document: Launch WPS Writer and open your existing Word (.docx) document seamlessly.
- 3. Utilize Smart Tools: Take advantage of the built-in Find and Replace and formatting tools to edit your text efficiently.

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.




