I don't know how you want it.
Just used msgbox.
Sub test()
Dim fn As String, txt As String, e, m As Object
Dim dic As Object, a(), n As Long, msg As String
fn = Application.GetOpenFilename("Word,*.doc*")
If fn = "False" Then Exit Sub
Set dic = CreateObject("Scripting.Dictionary")
For Each e In Range("a3", Range("a" & Rows.Count).End(xlUp)).Value
If e <> "" Then dic(CStr(e)) = Empty
Next
With CreateObject("Word.application")
txt = .documents.Open(fn).Content
.Quit
End With
With CreateObject("VBScript.RegExp")
.Global = True
.Pattern = "REQPROD[ :]*(\d{4,7})"
For Each m In .Execute(txt)
If Not dic.exists(m.submatches(0)) Then
n = n + 1: msg = msg & vbLf & m.submatches(0)
ReDim Preserve a(1 To n)
a(n) = m.submatches(0)
dic(m.submatches(0)) = Empty
End If
Next
End With
If msg = "" Then
MsgBox "No new ID"
Else
MsgBox n & " new id found" & msg
Range("a" & Rows.Count).End(xlUp)(2).Resize(n).Value = _
Application.Transpose(a)
End If
End Sub
Bookmarks