View Single Post
 
Old 10-16-2015, 02:25 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim strTxt As String, i As Long
strTxt = "|"
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[A-Z]{2} [0-9]{4,}"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    If InStr(strTxt, "|" & .Text & "|") = 0 Then
      strTxt = strTxt & .Text & "|"
    Else
      i = i + 1
      .HighlightColorIndex = wdYellow
    End If
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
MsgBox i & " duplicates found."
End Sub
Note: I've used the Find expression you specified, but that doesn't test the suffixes. You can decide whether that returns false matches.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote