Class HPageBreaks (Excel VBA)

The collection of horizontal page breaks within the print area. To use a HPageBreaks class variable it first needs to be instantiated, for example

For Each

Here is an example of processing the HPageBreaks items in a collection.


Dim shts As Sheets: Set shts = 
Dim hpgbr As HPageBreak
For Each hpgbr In shts.HPageBreaks
	With hpgbr
		
	End With
Next hpgbr

Add

Adds a horizontal page break.

Add (Before)

Before: A Range object. The range above which the new page break will be added.


With Worksheets(1) 
 .HPageBreaks.Add .Range("F25") 
 .VPageBreaks.Add .Range("F25") 
End With

Count

Returns a Long value that represents the number of objects in the collection.


Dim hpbs As HPageBreaks: Set hpbs = 
Dim lngCount As Long
lngCount = hpbs.Count

Item

Returns a single object from a collection.

Item (Index)

Index: The index number of the object.


Dim hpbs As HPageBreaks: Set hpbs = 
Dim hpgbrItem As HPageBreak
Set hpgbrItem = hpbs(Index:=1)