Sub test_lot()
For i = 4 To 2181
lenght = Len(Cells(i, 2))
If lenght = 1 Then
If Cells(i, 39) = Mid(Cells(i, 1), 2, lenght) & "000" & Cells(i, 2) Then
Cells(i, 40) = Cells(i, 39)
End If
ElseIf lenght = 2 Then
If Cells(i, 39) = Mid(Cells(i, 1), 2, lenght) & "00" & Cells(i, 2) Then
Cells(i, 40) = Cells(i, 39)
End If
ElseIf lenght = 3 Then
If Cells(i, 39) = Mid(Cells(i, 1), 2, lenght) & 0 & Cells(i, 2) Then
Cells(i, 40) = Cells(i, 39)
End If
End If
Next i
End Sub