ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count number of HPageBreaks on worksheet - examples (https://www.excelbanter.com/excel-programming/283977-count-number-hpagebreaks-worksheet-examples.html)

DataFreakFromUtah

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


All times are GMT +1. The time now is 08:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com