Count number of HPageBreaks on worksheet - examples

D

DataFreakFromUtah

No question here, just 1 function and 2 procedures for the archive.

Seach keywords/phrases:
Count the number of manual and horizontal page breaks in a worksheet.
Get the number of HPageBreaks in a worksheet.


Function PageBreaksHrzCount(SheetName As String) As Long

'Counts the number of horizontal page breaks in target wsheet
'both manual and automatic
PageBreaksHrzCount = Worksheets(SheetName).HPageBreaks.Count

End Function


Sub PageBreaksHCountM()

'Counts the number of manual horizontal page breaks on the
'active worksheet.

Dim HPB As HPageBreak
Dim N As Long
For Each HPB In ActiveSheet.HPageBreaks
If HPB.Type = xlPageBreakManual Then
N = N + 1
End If
Next HPB
MsgBox "There are " & N & " manual page breaks on this worksheet"

End Sub



Sub PageBreaksHCountMA()

'Counts the number of horiztonal manual & auto page breaks on the
'active worksheet.
Dim HBreaksCount As Integer
HBreaksCount = ActiveSheet.HPageBreaks.Count
MsgBox "There are " & HBreaksCount & " manual and automatic page
breaks on this sheet"

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top