|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("总表")
- r = .Cells(.Rows.Count, 27).End(xlUp).Row
- arr = .Range("aa1:aa" & r)
- For i = 10 To UBound(arr)
- If Not d.exists(arr(i, 1)) Then
- Set d(arr(i, 1)) = .Cells(i, 1).Resize(1, 30)
- Else
- Set d(arr(i, 1)) = Union(d(arr(i, 1)), .Cells(i, 1).Resize(1, 30))
- End If
- Next
- End With
- For Each aa In d.keys
- With Worksheets("模板")
- .Range("d3,f3,l3,a10:ad21") = ""
- d(aa).Copy .Range("a10")
- .Range("d3") = "户编号:" & .Range("ad10")
- .Range("f3") = "户主姓名:" & .Range("b10")
- .Range("l3") = "组别:" & .Range("z10")
- .Copy
- End With
- With ActiveWorkbook
- With .Worksheets(1)
- .Name = aa
- End With
- .SaveAs Filename:=ThisWorkbook.Path & "" & aa
- .Close False
- End With
- Next
- End Sub
复制代码 |
评分
-
3
查看全部评分
-
|