OOps, I didn't look at the picture... bit more complex than I thought...
Try
Sub test()
Dim r As Range, myPtn As String, i As Long, m As Object, temp, x
With Range("b3", Range("b" & Rows.Count).End(xlUp))
myPtn = Join(Filter(Evaluate("transpose(if(" & .Address & "<>""""," & _
.Address & ",char(2)))"), Chr(2), 0), Chr(2))
End With
With CreateObject("VBScript.RegExp")
.Global = True
.Pattern = "([$()\-\^|\\{}\[\]*+?.])"
myPtn = Replace(.Replace(myPtn, "\$1"), Chr(2), "|")
.Pattern = "\S*(" & myPtn & ")\S*"
For Each r In Range("a3", Range("a" & Rows.Count).End(xlUp))
temp = r.Value
If .test(r.Value) Then
For i = .Execute(r.Value).Count - 1 To 0 Step -1
Set m = .Execute(r.Value)(i)
x = Application.VLookup(m.submatches(0), Columns("b:c"), 2, False)
temp = Application.Replace(temp, m.firstindex + 1, m.Length, x)
Next
End If
r(, 4).Value = temp
Next
End With
End Sub
Bookmarks