Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Counting Manual Page Breaks Only

I have a very long spreadsheet where I've used vba to reset all page breaks
and then manually insert page breaks before key cells. I'm trying now to
count the number of manual page breaks using ActiveSheet.HPageBreaks.Count
but it appears to be counting both the manual and automatic (those reinserted
by excell between the manual breaks). Is there a way around this??
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Counting Manual Page Breaks Only

This function should return the value you want...

Function NumberOfManualPageBreaks(Optional WS As Worksheet) As Long
Dim HP As HPageBreak
If WS Is Nothing Then Set WS = ActiveSheet
For Each HP In WS.HPageBreaks
If HP.Type = xlPageBreakManual Then
NumberOfManualPageBreaks = NumberOfManualPageBreaks + 1
End If
Next
End Function

Simply pass it a reference to the worksheet whose manual horizontal page
breaks you want to count or omit the argument completely to return the
manual horizontal page break count for the active sheet.

--
Rick (MVP - Excel)


"Kevin R" wrote in message
...
I have a very long spreadsheet where I've used vba to reset all page breaks
and then manually insert page breaks before key cells. I'm trying now to
count the number of manual page breaks using ActiveSheet.HPageBreaks.Count
but it appears to be counting both the manual and automatic (those
reinserted
by excell between the manual breaks). Is there a way around this??


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Manual Page Breaks in VBA [email protected] Excel Programming 1 September 15th 08 01:26 AM
Dealing with automatic / manual page breaks Turquoise_dax Excel Discussion (Misc queries) 2 June 27th 06 02:50 PM
Remove all manual page breaks Otto Moehrbach Excel Programming 4 July 11th 05 07:43 AM
Count number of manual and automatic vertical page breaks - examples DataFreakFromUtah Excel Programming 0 January 13th 04 03:52 PM
Count the number of just the horizontal manual page breaks DataFreakFromUtah Excel Programming 1 November 27th 03 03:59 PM


All times are GMT +1. The time now is 09:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"