Sub setPageBreaks()
Const lPageLength As Long = 85
Dim lRow As Long
ActiveWindow.View = xlPageBreakPreview
With ActiveSheet
.ResetAllPageBreaks
For lRow = 1 + lPageLength To UsedRange.Rows.Count Step lPageLength
.HPageBreaks.Add before:=Rows(lRow)
Next lRow
End With
ActiveWindow.View = xlNormalView
End Sub
When I go to run it, it says, "run-time error '424'", "object required" ,
then it points me to "For lRow = 1 + lPageLength To UsedRange.Rows.Count Step
lPageLength"
Ok, that latest macro worked for what it was written for. But, what I
thought was going to work, doesn't. Now, I need it to do a page break ever
3rd time the word "print" appears. Any chance I could get a macro for that?
Set rCell = Columns(sSearchColumn).Find( _
what:=sSpecialWord, _
after:=Cells(Rows.Count, sSearchColumn), _
LookIn:=xlValues, _
lookat:=xlPart, _
searchorder:=xlByColumns, _
searchdirection:=xlNext, _
MatchCase:=False)
If rCell Is Nothing Then
MsgBox sSpecialWord & " not found"
Exit Sub
End If
sFirstFound = rCell.Address
iCount = 1
Do
Set rCell = Columns(sSearchColumn).FindNext(after:=rCell)
iCount = iCount + 1
If iCount = 3 Then
ActiveSheet.HPageBreaks.Add rCell
iCount = 0
End If
Loop Until rCell.Address = sFirstFound
End Sub
'------------------------------------------------------------