いろいろ調整必要ですが
まずは、表題の行判断できるかです。
下記は「表題」文字で判断していますが
高さが決まっている、罫線が決まっている
等どうなりますかね。?
VBA
1Sub tes()
2Dim WB As Workbook
3Dim Ws As Sheet1
4Set WB = ThisWorkbook
5Set Ws = WB.Sheets(1)
6
7Dim Vcnt As Long '現在の高さ計
8Dim Vmst As Long '一ページ分の高さ計
9Dim VcntBfo As Long 'ひとつ前の表の高さ計
10Dim MaxRow As Long 'A列の最終行
11Dim r2 As Long 'ひとつ前の表題
12
13Vmst = 702
14MaxRow = Ws.Cells(Rows.Count, 1).End(xlUp).Row
15r2 = 1
16Vcnt = 0
17Vcnt1 = 0
18
19For r = 1 To MaxRow
20 'If InStr(Cells(r, 1).Value, "表題") > 0 Then Exit For
21 If Cells(r, 1).Value = "表題" Then
22 If Vcnt + VcntBfo + Vcnt1 > Vmst Then
23 'Rows(r2).PageBreak = xlPageBreakManual '1個前の表題位置
24 Ws.Cells(r2, 1).PageBreak = xlPageBreakManual
25 End If
26 Vcnt = Vcnt + Vcnt1
27 VcntBfo = Vcnt1
28 Vcnt1 = 0
29 r2 = r
30 End If
31 Vcnt1 = Vcnt1 + Cells(r, 1).RowHeight
32Next
33
34End Sub
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。