View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
DataFreakFromUtah DataFreakFromUtah is offline
external usenet poster
 
Posts: 36
Default Count number of HPageBreaks on worksheet - examples

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