Advertisement
Guest User

Highlight Duplicates

a guest
Apr 1st, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub highlightdup()
  2.     Dim I, J As Long
  3.     Dim xRngFind, xRng As Range
  4.     Dim xStrFind, xStr As String
  5.     Options.DefaultHighlightColorIndex = wdYellow
  6.     Application.ScreenUpdating = False
  7.     With ActiveDocument
  8.         For I = 1 To .Paragraphs.Count - 1
  9.             Set xRngFind = .Paragraphs(I).Range
  10.             If xRngFind.HighlightColorIndex <> wdYellow Then
  11.                 For J = I + 1 To .Paragraphs.Count
  12.                     Set xRng = .Paragraphs(J).Range
  13.                     If xRngFind.Text = xRng.Text Then
  14.                         xRngFind.HighlightColorIndex = wdBrightGreen
  15.                         xRng.HighlightColorIndex = wdYellow
  16.                     End If
  17.                 Next
  18.             End If
  19.         Next
  20.     End With
  21. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement