how to automatically add page breaks?

M

mcie2

Is there a way to either write a macro or something else so that each time a
certain word appears (total) a page break inserts? It's a long report that I
need to print each totaled group on a separate page. It would be great if I
could somehow get the page breaks in without having to add each one manually.
 
J

Joel

Try this code. It searches column A for the word Add and puts a page break
after the row with the word ADD

ActiveSheet.ResetAllPageBreaks

LastRow = ActiveSheet.Cells. _
SpecialCells(Type:=xlCellTypeLastCell).Row
For RowCount = 1 To LastRow
If Range("A" & RowCount) = "Add" Then
ActiveSheet.HPageBreaks.Add _
before:=Rows(RowCount + 1)
End If
Next RowCount
 

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