|
代码如下。。。
Sub test()
arr = Sheet1.UsedRange
Set d = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
s = arr(i, 2)
If s <> "" Then
If Not d.exists(s) Then Set d(s) = CreateObject("scripting.dictionary")
d(s)(i) = Application.Index(arr, i)
End If
Next
For Each k In d.keys
ReDim brr(1 To 10000, 1 To 12)
n = 0
Worksheets("模板").Copy After:=Worksheets(Sheets.Count)
With ActiveSheet
.[b1] = k
For Each Item In d(k).items
n = n + 1
brr(n, 1) = Item(17)
brr(n, 2) = Item(8)
brr(n, 3) = Item(6)
brr(n, 4) = Item(7)
brr(n, 5) = Item(10)
brr(n, 7) = Item(11)
brr(n, 9) = Item(16)
brr(n, 11) = Item(15)
brr(n, 12) = Item(19)
n = n + 1
brr(n, 3) = Item(9)
brr(n, 7) = Item(12)
brr(n, 11) = Item(13)
brr(n, 12) = Item(18)
Next
.[a7].Resize(n, 12) = brr
.Name = k
End With
Next
Set d = Nothing
End Sub
|
|