|
Sub test() '这样啊,请测试
Dim d As Object, ar(), br, tp, r&, c%, s$, y&
Application.ScreenUpdating = False
Set d = CreateObject("scripting.dictionary")
With Sheets("sheet2")
tp = .Range("a6:c" & .Cells(.Rows.Count, 1).End(xlUp).Row)
End With
For r = 1 To UBound(tp)
If Not d.exists(tp(r, 1)) Then d(tp(r, 1)) = r
Next
With Sheets("sheet1")
br = .Range("a6:a" & .Cells(.Rows.Count, 1).End(xlUp).Row)
ReDim ar(1 To UBound(br), 1 To 2)
For r = 1 To UBound(ar)
s = br(r, 1)
If d.exists(s) Then
y = d(s)
For c = 2 To 3
ar(r, c - 1) = tp(y, c)
Next
End If
Next
.[b6].Resize(UBound(ar), 2) = ar
End With
d.RemoveAll
With Sheets("sheet2")
tp = .Range("e6:h" & .Cells(.Rows.Count, 5).End(xlUp).Row)
End With
For r = 1 To UBound(tp)
If Not d.exists(tp(r, 1)) Then d(tp(r, 1)) = r
Next
With Sheets("sheet1")
br = .Range("d6:d" & .Cells(.Rows.Count, 4).End(xlUp).Row)
ReDim ar(1 To UBound(br), 1 To 4)
For r = 1 To UBound(ar)
s = Left(br(r, 1), 3)
ar(r, 1) = s
If d.exists(s) Then
y = d(s)
For c = 2 To 4
ar(r, c) = tp(y, c)
Next
End If
Next
.[e6].Resize(UBound(ar), 4) = ar
End With
d.RemoveAll
With Sheets("sheet2")
tp = .Range("k6:m" & .Cells(.Rows.Count, 11).End(xlUp).Row)
End With
For r = 1 To UBound(tp)
If Not d.exists(tp(r, 1)) Then d(tp(r, 1)) = r
Next
With Sheets("sheet1")
br = .Range("k6:k" & .Cells(.Rows.Count, 11).End(xlUp).Row)
ReDim ar(1 To UBound(br), 1 To 2)
For r = 1 To UBound(ar)
s = br(r, 1)
If d.exists(s) Then
y = d(s)
For c = 2 To 3
ar(r, c - 1) = tp(y, c)
Next
End If
Next
.[l6].Resize(UBound(ar), 2) = ar
End With
Set d = Nothing
Application.ScreenUpdating = True
End Sub |
评分
-
1
查看全部评分
-
|