|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:h" & r)
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 3)) Then
- Set d(arr(i, 3)) = CreateObject("scripting.dictionary")
- End If
- d(arr(i, 3))(i) = Empty
- Next
- End With
- With Worksheets("模板")
- For Each aa In d.Keys
- .Range("b2,d2,b4:f5") = Empty
- ReDim brr(1 To 5, 1 To 6)
- m = 0
- For Each bb In d(aa).Keys
- m = m + 1
- If m = 1 Then
- xz = arr(bb, 2)
- hz = arr(bb, 3)
- End If
- brr(m, 1) = m
- For j = 4 To 8
- brr(m, j - 2) = arr(bb, j)
- Next
- Next
- .Range("b2") = xz
- .Range("d2") = hz
- .Range("a4").Resize(UBound(brr), UBound(brr, 2)) = brr
- On Error Resume Next
- Worksheets(hz).Delete
- On Error GoTo 0
- .Copy after:=Worksheets(Worksheets.Count)
- ActiveSheet.Name = hz
-
- Next
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|