|
Sub test()
Application.ScreenUpdating = False
Dim ar As Variant
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("数据源")
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a1:f" & r)
End With
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
d(ar(i, 1)) = ""
End If
Next i
For Each k In d.keys
n = 0
ReDim br(1 To UBound(ar), 1 To 4)
For i = 2 To UBound(ar)
If ar(i, 1) = k Then
n = n + 1
br(n, 1) = ar(i, 1)
br(n, 2) = ar(i, 3)
br(n, 3) = ar(i, 4)
br(n, 4) = ar(i, 5)
End If
Next i
Sheets("统计表").Copy
Set wb = ActiveWorkbook
With wb.Worksheets(1)
.[a4].Resize(n, UBound(br, 2)) = br
.[a4].Resize(n, UBound(br, 2) + 1).Borders.LineStyle = 1
End With
wb.SaveAs Filename:=ThisWorkbook.Path & "\走访工作表_" & Format(k, "yyyymmdd")
wb.Close
Next k
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
评分
-
1
查看全部评分
-
|