|
模糊匹配。订单号表1包含表2的情况。- Sub ykcbf() '//2024.6.28
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("Sheet1")
- p = ThisWorkbook.Path
- f = p & "\1.xls"
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets("Sheet1")
- arr = .UsedRange
- wb.Close 0
- End With
- For i = 2 To UBound(arr)
- s = arr(i, 2) & "|" & arr(i, 6)
- d(s) = arr(i, 12)
- Next
- With sh
- r = .Cells(Rows.Count, 1).End(3).Row
- For i = 2 To r
- s = .Cells(i, 1) & "|" & .Cells(i, 2)
- For Each k In d.keys
- If InStr(k, .Cells(i, 2)) Then
- If InStr(k, .Cells(i, 1)) Then
- .Cells(i, 3) = d(k)
- Exit For
- End If
- End If
- Next
- Next
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|