Page Break

G

Guest

I need Excel to insert a page break at every blank row. The number of rows
per page will be different each time I run the report, so the row number will
change each time. I have been inserting the page breaks manually, but it is
a very time consuming process with such a long report.
 
R

Ron de Bruin

Hi Sheri

Try this tester
I check all blanks in A1:A20

Sub Insert_PageBreaks()
Dim cell As Range
ActiveSheet.ResetAllPageBreaks
On Error Resume Next
For Each cell In Range("A1:A20").SpecialCells(xlCellTypeBlanks)
ActiveSheet.HPageBreaks.Add Before:=Cells(cell.Row, 1)
Next
On Error GoTo 0
End Sub
 

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