|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 套打()
Application.ScreenUpdating = False
Dim ar As Variant
Dim i As Long, r As Long
Dim br()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("sheet1")
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "成绩表为空!": End
ar = .Range(.Cells(1, 1), .Cells(r, 19))
End With
For i = 2 To UBound(ar)
If ar(i, 1) <> "" Then
If d(ar(i, 1)) = "" Then
d(ar(i, 1)) = i
Else
d(ar(i, 1)) = d(ar(i, 1)) & "|" & i
End If
End If
Next i
With Sheets("打印模板")
For Each k In d.keys
rr = Split(d(k), "|")
n = 0
ReDim br(1 To UBound(rr) + 1, 1 To UBound(ar, 2))
For s = 0 To UBound(rr)
xh = rr(s)
n = n + 1
For j = 1 To UBound(ar, 2)
br(n, j) = ar(xh, j)
Next j
Next s
.[a1].CurrentRegion.Offset(1).Borders.LineStyle = 0
.[a1].CurrentRegion.Offset(1) = Empty
.[a2].Resize(n, UBound(br, 2)) = br
.[a2].Resize(n, UBound(br, 2)).Borders.LineStyle = 1
With ActiveSheet.PageSetup
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
.PrintOut
Next k
End With
Application.ScreenUpdating = True
MsgBox "打印完毕!"
End Sub
|
评分
-
2
查看全部评分
-
|