'有一处不一样,确认一下,,,
Option Explicit
Sub test()
Dim arr, brr, i, j, k, t, p
arr = Sheets("产品型号及项目").[a1].CurrentRegion.Resize(, 2)
Sheets("模糊查找").Activate
brr = [a1].CurrentRegion.Resize(, 3)
For i = 2 To UBound(brr, 1)
For j = 2 To UBound(arr, 1)
p = InStr(brr(i, 1), arr(j, 1))
If p > 0 Then Exit For
Next
If j = UBound(arr, 1) + 1 Then
brr(i, 2) = vbNullString
For j = 2 To UBound(arr, 1)
If InStr(brr(i, 1), arr(j, 2)) Then Exit For
Next
If j = UBound(arr, 1) + 1 Then
brr(i, 3) = vbNullString
Else
brr(i, 3) = arr(j, 2)
End If
Else
brr(i, 2) = arr(j, 1)
If InStr(brr(i, 1), arr(j, 2)) Then
If InStr(brr(i, 1), arr(j, 2)) <> p Then
brr(i, 3) = arr(j, 2)
Else
If InStr(p + 1, brr(i, 1), arr(j, 2)) Then
brr(i, 3) = arr(j, 2)
Else
brr(i, 3) = vbNullString
End If
End If
Else
brr(i, 3) = vbNullString
End If
End If
Next
[e1].Resize(UBound(brr, 1), UBound(brr, 2)) = brr
End Sub |