|
Sub test()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
ar = Sheets("表一").[a1].CurrentRegion
For i = 3 To UBound(ar)
If Trim(ar(i, 4)) <> "" Then
d(Trim(ar(i, 4))) = ""
End If
Next i
For Each k In d.keys
n = 0
ReDim br(1 To UBound(ar), 1 To 6)
For i = 3 To UBound(ar)
If Trim(ar(i, 4)) = k Then
n = n + 1
br(n, 1) = ar(i, 5)
br(n, 2) = ar(i, 6)
br(n, 5) = ar(i, 12)
br(n, 6) = ar(i, 8)
If Trim(ar(i, 12)) = "户主" Then
hz = ar(i, 6)
End If
zz = ar(i, 9)
End If
Next i
With Sheets("通知")
.Range("a6:f27") = Empty
.[b2] = k
.[d2] = n
.[b3] = hz
.[b4] = zz
.[a6].Resize(n, UBound(br, 2)) = br
.Copy
End With
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "\" & hz & ".pdf" _
, Quality:=xlQualityMinimum, IncludeDocProperties:=False, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
ActiveWorkbook.Close False
Next k
End Sub
|
|