View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nick Hodge Nick Hodge is offline
external usenet poster
 
Posts: 1,173
Default Finding existing manual pagebreaks

Ragnar

Something like this will do it

Sub DiscoverPageBreaks()
Dim rng As Range
Dim pbState As Integer
Dim lManBreak As Integer, lAutoBreak As Long
lManBreak = 0
lAutoBreak = 0
For Each rng In Range("A1:A500")
pbState = Rows(rng.Row).PageBreak
If pbState = xlPageBreakManual Then
MsgBox "There is a manual page break at: " & rng.Address, vbOKOnly
lManBreak = lManBreak + 1
ElseIf pbState = xlPageBreakAutomatic Then
MsgBox "There is a automatic page break at: " & rng.Address, vbOKOnly
lAutoBreak = lAutoBreak + 1
End If
Next rng
MsgBox "There are a total of " & lManBreak + lAutoBreak & " page break(s)" &
Chr(13) _
& lManBreak & " manual page break(s) and " & _
Chr(13) & lAutoBreak & " automatic page break(s)", _
vbInformation + vbOKOnly
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Ragnar Midtskogen" wrote in message
...
Hello,

How would I go about finding locations of horizontal pagebreaks by
stepping through all the rows in a sheet?

I am already stepping through the sheet looking for presence of a certain
value in a column and I would like to locate any manual pagebreaks as I
go.

I have looked at all the documentation in Excel but I find it kind of
convoluted and confusing.

Any help would be appreciated.

Ragnar