|
Sub 分页()
Application.ScreenUpdating = False
Dim ar As Variant
Dim br()
With Sheets("工作表1")
r = .Cells(Rows.Count, 11).End(xlUp).Row
ar = .Range("k2:l" & r)
rs = .Cells(Rows.Count, 1).End(xlUp).Row
If rs >= 3 Then .Range("a3:f" & rs) = Empty
For i = 1 To UBound(ar) Step 120
n = 0
ReDim br(1 To UBound(ar), 1 To 6)
y = 0
For s = i To i + 119 Step 40
y = y + 2
If s <= UBound(ar) Then
For ss = s To s + 39
If ss <= UBound(ar) Then
If Trim(ar(ss, 1)) <> "" Then
n = n + 1
If n > 40 Then
n = 1
Else
n = n
End If
br(n, y - 1) = ar(ss, 1)
br(n, y) = ar(ss, 2)
End If
End If
Next ss
End If
Next s
ws = .Cells(Rows.Count, 1).End(xlUp).Row + 1
.Cells(ws, 1).Resize(n, y) = br
.Cells(ws, 1).Resize(n, y).Borders.LineStyle = 1
Next i
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|