Count the number of just the horizontal manual page breaks

D

DataFreakFromUtah

Win 2000
Excel 2000

Hello,
I am trying to find a way to count just the number of manual
horizontal
page breaks in the active worksheet. The count should not include
the number of automatic horizontal page breaks. I have a procedure
below that gives me both (manual & automatic), but I can't find
a way to isolate for just the manual count.


I need to incorporate xlPageBreakManual into the procedure I think,
but
I'm sure how to do this.
I would appreciate any help that could be provided.
Thank you so much.
Tom


Sub PageBreaksHCount()
'Counts the number of horiztonal page breaks (both manual & automatic)
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
 
C

Chip Pearson

Try something like the following:

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"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

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