Worksheet.HPageBreaks Property (Excel)
Returns an HPageBreaks collection that represents the horizontal page breaks on the sheet. Read-only.
Syntax
식 .HPageBreaks
식 A variable that represents a Worksheet object.
Remarks
There is a limit of 1,026 horizontal page breaks per sheet.
Example
The following code example displays the number of full-screen and print-area horizontal page breaks.
For Each pb in Worksheets(1).HPageBreaks
If pb.Extent = xlPageBreakFull Then
cFull = cFull + 1
Else
cPartial = cPartial + 1
End If
Next
MsgBox cFull & " full-screen page breaks, " & cPartial & _
" print-area page breaks"
Sample code provided by: Bill Jelen, MrExcel.com | About the Contributor
The following code example adds a page break when the value of a cell in column A changes.
Sub AddPageBreaks()
StartRow = 2
FinalRow = Range("A65536").End(xlUp).Row
LastVal = Cells(StartRow, 1).Value
For i = StartRow To FinalRow
ThisVal = Cells(i, 1).Value
If Not ThisVal = LastVal Then
ActiveSheet.HPageBreaks.Add before:=Cells(i, 1)
End If
LastVal = ThisVal
Next i
End Sub
About the Contributor
MVP인 Bill Jelen은 Microsoft Excel에 대한 서적을 다수 집필했습니다. 또한 Leo Laporte와 함께 TechTV에 고정 출연하고 있으며, Excel과 관련한 30만 건 이상의 질문과 대답이 제공되는 MrExcel.com(영문일 수 있음)의 운영자이기도 합니다.