Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in


How to find and highlight duplicate paragraphs in Word document?

Supposing, you have a large Word document which may have hundreds of pages, now, you want to check if there are duplicate paragraphs and then highlight to make them outstanding, so that you can deal with the duplicate sentences. How could you find and highlight the duplicate paragraphs quickly and easily in Word document?

Find and highlight the duplicate paragraphs in Word document with VBA code

Find and highlight the duplicate paragraphs in Word document with VBA code

To find and highlight the duplicate paragraphs in a Word document, the following VBA code can do you a favor, please do as this:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. And then, click Insert > Module, copy and paste below code into the opened blank module:

VBA code: Find and highlight the duplicate paragraphs in Word document:

Sub highlightdup()
    Dim I, J As Long
    Dim xRngFind, xRng As Range
    Dim xStrFind, xStr As String
    Options.DefaultHighlightColorIndex = wdYellow
    Application.ScreenUpdating = False
    With ActiveDocument
        For I = 1 To .Paragraphs.Count - 1
            Set xRngFind = .Paragraphs(I).Range
            If xRngFind.HighlightColorIndex <> wdYellow Then
                For J = I + 1 To .Paragraphs.Count
                    Set xRng = .Paragraphs(J).Range
                    If xRngFind.Text = xRng.Text Then
                        xRngFind.HighlightColorIndex = wdBrightGreen
                        xRng.HighlightColorIndex = wdYellow
                    End If
            End If
    End With
End Sub

3. And then press F5 key to run this code, all the duplicate sentences are highlighted at once, the first displayed duplicate paragraphs are highlighted with green color, and other duplicates are highlighted with yellow color, see screenshot:

doc highlight dup sentences 1

Recommended Productivity Tools

shot kutools word kutools tab 1180x121
shot kutools word kutools plus tab 1180x120

Kutools For Word - More Than 100 Advanced Features For Microsoft Word, Save Your 60% Time

  • Complicated and repeated operations can be done a one-time processing in seconds.
  • Insert multiple images across folders into Word document at once.
  • Merge and combine multiple Word files across folders in to one with your desired order.
  • Split the current document into separate documents according to heading 1, section break or other criteria.
  • Convert files between Doc and Docx, Docx and PDF, collection of tools for common conversions and selection, and so on...
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    dvid · 7 months ago
    I tried, and it works fine!
    I just wanted to know - could I do the same thing - but not a whole paragraph, but a sentence with a few words I'd set up - like 10 words?
  • To post as a guest, your comment is unpublished.
    Juliana · 7 months ago
    Tentei e não funcionou, só da que parou de funcionar.