Try next code and comment
Option Explicit
Option Base 1
Sub PrepareData()
Dim ObjDic As Object
Dim NbRef As Object
Dim REF()
Dim LastRow1 As Long, LastRow2 As Long
Dim I As Long, J As Long, K As Long
Dim J_Ref As Long
Dim TEMP
Set ObjDic = CreateObject("Scripting.Dictionary")
LastRow2 = Range("C" & Rows.Count).End(xlUp).Row
ReDim REF(1 To LastRow2, 1 To 2)
For I = 2 To LastRow2
TEMP = Split(Cells(I, "C"), " ")
If (UBound(REF, 2) < UBound(TEMP, 1) + 1) Then
ReDim Preserve REF(1 To UBound(REF, 1), 1 To UBound(TEMP, 1) + 1)
End If
For J = 0 To UBound(TEMP, 1)
REF(I, J + 1) = TEMP(J)
Next J
Next I
LastRow1 = Range("A" & Rows.Count).End(xlUp).Row
For I = 2 To LastRow1
For J = 2 To LastRow2
For K = 1 To UBound(REF, 2)
If ((REF(J, K) <> Empty) And (Len(REF(J, K)) > 1)) Then
If (Len(Cells(I, "A")) - Len(Replace(Cells(I, "A"), REF(J, K), "")) > 0) Then
If (ObjDic.exists(J)) Then
ObjDic.Item(J) = ObjDic.Item(J) + 1
Else
ObjDic.Add J, 1
End If
If (ObjDic.Item(J) = WorksheetFunction.Large(ObjDic.items, 1)) Then J_Ref = J
End If
End If
Next K
Next J
Cells(I, "B") = Cells(J_Ref, "C")
ObjDic.RemoveAll
Next I
End Sub
Bookmarks