|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub Button1025_Click()
Set d = CreateObject("scripting.dictionary")
arr = Sheets("考场库").UsedRange
brr = Array("座位号:", "姓名:", "考场号:", "准考证号:")
For j = 2 To UBound(arr)
d(arr(j, 5)) = d(arr(j, 5)) & "," & j
Next j
Application.ScreenUpdating = False
Sheets("桌签模版").Select
n = 0
For Each k In d.keys
n = n + 1
ActiveSheet.UsedRange.ClearContents
crr = Split(d(k), ",")
x = 2
c = 1
If UBound(crr) Mod 32 = 0 Then
w = UBound(crr) / 32
Else
w = Int(UBound(crr) / 32) + 1
End If
n = 1
For j = 1 To UBound(crr)
Cells(x, c) = brr(0) & k
r = Val(crr(j))
Cells(x + 1, c) = brr(0) & arr(r, 2)
Cells(x + 2, c) = brr(1) & arr(r, 4)
Cells(x + 3, c) = brr(2) & arr(r, 3)
x = x + 6
If x > 45 Then
c = c + 1
If c = 5 Then
[a1:d48].PrintOut
f = ThisWorkbook.Path & "\" & k & "-" & arr(r, 6) & arr(r, 7) & "(" & w & "-" & n & ").pdf"
[a1:d48].ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
f, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
x = 2
c = 1
n = n + 1
ActiveSheet.UsedRange.ClearContents
End If
End If
Next j
If UBound(crr) Mod 32 <> 0 Then
[a1:d48].PrintOut
f = ThisWorkbook.Path & "\" & k & "-" & arr(r, 6) & arr(r, 7) & "(" & w & "-" & n & ").pdf"
[a1:d48].ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
f, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
End If
Next k
Application.ScreenUpdating = True
End Sub
|
|