|
楼主 |
发表于 2024-3-14 09:21
|
显示全部楼层
添加了
我在最后添加上去,只有第一页的30行添加了分页符。后边页数没有添加。
是加错地方吗?
Sub 书() '书生答题专用
ar = [a1].CurrentRegion
Dim br
Set d = CreateObject("scripting.dictionary")
For i = 2 To UBound(ar)
d(ar(i, 1)) = d(ar(i, 1)) & "-" & i
Next
ReDim br(665536, UBound(ar, 2) - 1)
dd = d.items
k = 0
For Each r In d.keys
aaa = Split(Mid(d(r), 2), "-")
If n > 0 Then k = k + (30 - n)
n = 30
For i = 0 To UBound(aaa)
If n = 30 Then
For ij = 1 To 8
br(k, ij - 1) = ar(1, ij)
Next
n = 0: k = k + 1
End If
For ij = 1 To 8
br(k, ij - 1) = ar(aaa(i), ij)
Next
n = n + 1
k = k + 1
Next
Next
Sheets(2).[n1].Resize(k, 8) = br
ThisWorkbook.Worksheets("Sheet1").Rows(30).PageBreak = xlPageBreakManual
End Sub |
|