Since we have to search for part of the substring in a string, (lookin:=xlPart), we just need to test and make sure the part searched for matches the left part found.
Sub AddGraphIdx()
Dim WS_PN As Worksheet
Dim WS_Idx As Worksheet
Dim A As Long
Dim LR_PN As Long
Dim LR_Idx As Long
Dim C As Range
Set WS_Idx = Worksheets("Sheet3")
With WS_Idx
LR_Idx = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Set WS_PN = Worksheets("Sheet2")
With WS_PN
LR_PN = .Cells(.Rows.Count, "A").End(xlUp).Row
For A = 2 To LR_Idx
With .Range("C2:C" & LR_PN)
Set C = .Find(WS_Idx.Range("A" & A), LookIn:=xlValues, lookat:=xlPart)
If Not C Is Nothing Then
firstAddress = C.Address
Do
If Left(C, Len(WS_Idx.Range("A" & A))) = WS_Idx.Range("A" & A) Then
C.Offset(, 8).Value = WS_Idx.Range("B" & A)
Set C = .FindNext(C)
End If
Loop While Not C Is Nothing And C.Address <> firstAddress
End If
End With
Next
End With
End Sub
Bookmarks