自動水平改ページがワークシート上でどう落ちるかをクリーンアップしようとしています。自動ページ区切りが列「D」のフレーズ「全体的な状態」の上に壊れていない場合、「全体的な状態」の下の次の最も近い水平の改ページを移動したいと思います。以下は、列Dの「Overall Status」と呼ばれるすべての行の上に水平改ページを配置するコードスニペットですが、ページブレイクが多すぎます。既存の水平改ページは現在、該当する場所最も近い自動水平改ページをキーワード行まで移動します。
Sub Pagebreak()
'adds horizontal pagebreak before every 'Overall Status'
Dim Search As String
Search = "Overall Status"
With ActiveSheet.UsedRange
Set c = .Find(What:=Search, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=c
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
'Then try toggle between pagebreak screen and normal view
End With
End Sub
以下のコードのスニペットは示しています
Sub HPageBreakTest()
'counts and shows where horizontal pagebreaks are
Dim pgeBreak As HPageBreak
With ActiveSheet
.Cells(65536, 1).Select
MsgBox .HPageBreaks.Count & " Horizontal page breaks counted"
For Each pgeBreak In .HPageBreaks
MsgBox "pgbreak at row: " & pgeBreak.Location.row
.Cells(65536, 1).Select
Next pgeBreak
.Cells(1, 1).Select
End With
End Sub
私は(1に、これら2つのコードスニペットのロジックを組み合わせることができます方法を理解したいと思います)最初の自動水平ページ区切りを「Overall Status」の下に配置し、(2)そのページをD列の「Overall Status」句のすぐ上に移動します。「Overall Status」の各インスタンスの水平ページ区切りではありません。私の質問が意味をなさないことを願う。ご協力いただきありがとうございます。
ありがとう、悩まされたお父さん!私はちょうどあなたの解決策を試しました(上記)、それは治療を働くように見えます! – XLmatters