Wali, I don't think a lack of precision was the problem! Try this, it seems to do what you want:
Sub x()
Dim rng As Range, rWord As Range, sRef As String, sFind As String
sRef = "°°"
Range("D2", Range("D2").End(xlDown)).Replace What:=" " & sRef, Replacement:=sRef, Lookat:=xlPart
For Each rng In Range("D2", Range("D2").End(xlDown))
If InStr(rng, sRef) > 0 Then
sFind = Mid(rng, InStr(rng, sRef) - 2, 2)
Set rWord = Range("A2", Range("A2").End(xlDown)).Find(What:=sFind, Lookat:=xlPart)
If Not rWord Is Nothing Then
rng.Replace What:=sRef, Replacement:=sRef & "{{" & rWord.Offset(, 3) & "}}", Lookat:=xlPart
End If
End If
Next rng
End Sub
EDIT: this assumes your word refs (eg W1) are two characters so if your actual data are different the code will have to be revised.
EDIT2: this should overcome the above:
Sub x()
Dim rng As Range, rWord As Range, sRef As String, sFind As String, v, i As Long
sRef = "°°"
Range("D2", Range("D2").End(xlDown)).Replace What:=" " & sRef, Replacement:=sRef, Lookat:=xlPart
For Each rng In Range("D2", Range("D2").End(xlDown))
If InStr(rng, sRef) > 0 Then
v = Split(rng, ",")
For i = LBound(v) To UBound(v)
If InStr(v(i), sRef) > 0 Then
sFind = Trim(WorksheetFunction.Substitute(v(i), sRef, ""))
Set rWord = Range("A2", Range("A2").End(xlDown)).Find(What:=sFind, Lookat:=xlWhole)
If Not rWord Is Nothing Then
rng.Replace What:=sRef, Replacement:=sRef & "{{" & rWord.Offset(, 3) & "}}", Lookat:=xlPart
End If
Exit For
End If
Next i
End If
Next rng
End Sub
Bookmarks