Sub 生成准考证()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With Worksheets("sheet1")
.AutoFilterMode = False
r = .Cells(.Rows.Count, 1).End(xlUp).Row
arr = .Range("a1:n" & r)
End With
With Worksheets("准考证打印 (2)")
.UsedRange.Offset(11).Clear
Range("B3:B4,D3:D4,G3:G4,I3:I4,I9:I10,G9:G10,D9:D10,B9:B10") = Empty
.Cells.NumberFormatLocal = "@"
If (r - 1) / 2 = Int((r - 1) / 2) Then
sl = (r - 1) / 2
Else
sl = Int((r - 1) / 2) + 1
End If
m = 12
For i = 2 To sl
.Rows("1:11").Copy .Cells(m, 1)
m = m + 11
Next i
m = 3
For i = 2 To UBound(arr) Step 2
.Cells(m, 2) = arr(i, 3)
.Cells(m, 4) = arr(i, 13)
.Cells(m + 1, 2) = arr(i, 8)
.Cells(m + 1, 4) = arr(i, 14)
.Cells(m + 6, 2) = arr(i, 3)
.Cells(m + 6, 4) = arr(i, 13)
.Cells(m + 7, 2) = arr(i, 8)
.Cells(m + 7, 4) = arr(i, 14)
If i + 1 <= UBound(arr) Then
.Cells(m, 7) = arr(i + 1, 3)
.Cells(m, 9) = arr(i + 1, 13)
.Cells(m + 1, 7) = arr(i + 1, 8)
.Cells(m + 1, 9) = arr(i + 1, 14)
.Cells(m + 6, 7) = arr(i + 1, 3)
.Cells(m + 6, 9) = arr(i + 1, 13)
.Cells(m + 7, 7) = arr(i + 1, 8)
.Cells(m + 7, 9) = arr(i + 1, 14)
End If
m = m + 11
Next i
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "ok!"
End Sub
|