Sub SearchForDepo() Dim regEx, Match, Matches Set regEx = New RegExp regEx.Pattern = "\bDepo[ \.][^:]{1,40}[0-9]+:[:\-0123456789, ]+" regEx.IgnoreCase = True regEx.Global = True Set Matches = regEx.Execute(ActiveDocument.Range.Text) Dim strCitations As String Dim dictCitations As Scripting.Dictionary Set dictCitations = New Scripting.Dictionary For Each Match In Matches Dim strCurrentCite As String strCurrentCite = Trim(Match.Value) Dim fields() As String fields() = Split(strCurrentCite, ",") HighlightString (strCurrentCite) For i = 0 To UBound(fields) fields(i) = Trim(fields(i)) If Right(fields(i), 1) = ":" Then ' if the citation was followed by a ":", we want to get rid of that fields(i) = Left(fields(i), Len(fields(i)) - 1) End If If Len(fields(i)) > 2 Then ' dont want the trailing comma Dim strCurrentTitle As String Dim rxDepo As RegExp Set rxDepo = New RegExp rxDepo.Pattern = "[0-9]+:[:\-0123456789]+" rxDepo.IgnoreCase = True rxDepo.Global = True Set mchDepo = rxDepo.Execute(fields(i)) Dim strCurrentPage As String strCurrentPage = mchDepo(0).Value If i = 0 Then strCurrentTitle = Left(fields(i), Len(fields(i)) - Len(strCurrentPage)) If Right(strCurrentTitle, 2) = "p." Then strCurrentTitle = Left(strCurrentTitle, Len(strCurrentTitle) - 2) End If End If Dim strCurrentList As String strCurrentList = "" If dictCitations.Exists(strCurrentTitle) Then strCurrentList = dictCitations.Item(strCurrentTitle) & vbCrLf & strCurrentPage Else strCurrentList = strCurrentPage End If dictCitations.Item(strCurrentTitle) = strCurrentList End If Next i Next Dim strOutput As String strOutput = "" For Each cit In dictCitations.Keys strOutput = strOutput & cit & vbCrLf & dictCitations.Item(cit) & vbCrLf & vbCrLf Next Dim doOutput As New DataObject doOutput.SetText strOutput doOutput.PutInClipboard 'MsgBox "Data put onto clipboard. Paste it to use it." MsgBox strOutput End Sub Sub HighlightString(strText As String) Options.DefaultHighlightColorIndex = wdYellow With Selection.Find .ClearFormatting .Replacement.ClearFormatting .Replacement.Highlight = True .Replacement.Text = "^&" .Forward = True .Format = True .MatchWholeWord = False .MatchAllWordForms = False .MatchCase = False .MatchWildcards = False End With With Selection.Find .Wrap = wdFindContinue .Text = strText .Execute Replace:=wdReplaceAll End With With Selection.Find .ClearFormatting .Replacement.ClearFormatting End With End Sub