|
Option Explicit
Sub test()
Dim ar, i&, dic As Object, Rng As Range
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
With Range("F1", Cells(Rows.Count, "K").End(xlUp))
ar = .Value
Set Rng = .Cells(1, 5).Resize(, 2)
For i = 2 To UBound(ar)
If Not dic.exists(ar(i, 1)) Then
Set dic(ar(i, 1)) = Rng
End If
Set dic(ar(i, 1)) = Union(dic(ar(i, 1)), .Cells(i, 5).Resize(, 2))
Next
End With
For i = 0 To dic.Count - 1
With Worksheets(Cells(i + 2, 1).Value)
.Cells.Clear
dic.items()(i).Copy .[O1]
End With
Next i
Range("D1", Cells(Rows.Count, "D").End(xlUp)).Offset(1).Clear
[d2].Resize(dic.Count) = Application.Transpose(dic.keys)
Set dic = Nothing: Set Rng = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
1
查看全部评分
-
|