|
Sub 匹配数据()
Application.ScreenUpdating = False
Dim d As Object
Set d = CreateObject("scripting.dictionary")
Set sh = ThisWorkbook.ActiveSheet
r = sh.Cells(Rows.Count, 3).End(xlUp).Row
For i = 7 To r
If Trim(sh.Cells(i, 3)) <> "" And Trim(sh.Cells(i, 5)) <> "" Then
zf = Trim(sh.Cells(i, 3)) & "|" & Trim(sh.Cells(i, 5))
d(zf) = i
End If
Next i
mc = sh.Name
f = Dir(ThisWorkbook.Path & "\B工作簿.xls*")
If f = "" Then MsgBox "找不到数据源文件!": Exit Sub
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & f, 0)
With wb.Worksheets(mc)
rs = sh.Cells(Rows.Count, 3).End(xlUp).Row
For i = 7 To rs
If Trim(.Cells(i, 3)) <> "" And Trim(.Cells(i, 5)) <> "" Then
zf_1 = Trim(.Cells(i, 3)) & "|" & Trim(.Cells(i, 5))
m = d(zf_1)
If m <> "" Then
sh.Cells(m, 6) = .Cells(i, 6)
End If
End If
Next i
End With
wb.Close False
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|