|
Page Break |
|
Excel automatically inserts
page breaks based on the print setting and
displays them providing the setting in
Tools>Options...>View is selected. This option
inserts a manual page break(s) above and to the
left of the active cell. If you do not want a
page break to the left, either select the entire
row or a cell in column A. A 'manual' page
break is signified with a 'long' dotted line as
opposed to a 'built-in' one which has a
'shorter' dotted line. Automatic page breaks are
re-calculated after inserting any manual page
breaks. This menu option toggles to 'Remove page
break' when you select a cell directly below or
to the right of an existing manual page break.
You may find it easier to add, delete or
manipulate manual page breaks using 'Page
Break Preview' under the 'View' menu. |
|
Sub InsertManualPageBreak()
'Insert a page break at row 50
Range("A50").PageBreak = xlPageBreakManual
End Sub
Sub DeleteManualPageBreak()
'Deletes a page break at row 50
Range("A50").PageBreak = xlPageBreakNone
End SububSub DiscoverPageBreaks()
'Finds horizontal page break in the range
'A1:A500 and discovers if they are automatic
'or manual. Displays addresses as it goes and
'then a total broken down by the two types
'auto and manual
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 |