How to insert page break after every 10 rows?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Could anybody help me with the VBA-code needed ub this? I have 3000 rows in
one sheet and I would like to print only 10 rows for each paper.
 
One way:

Option Explicit
Sub testme()
Dim myCell As Range
Dim iRow As Long
Dim LastRow As Long
Dim FirstRow As Long

With Worksheets("Sheet1")
FirstRow = 11
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

.ResetAllPageBreaks

For iRow = FirstRow To LastRow Step 10
.Cells(iRow, "A").PageBreak = xlPageBreakManual
Next iRow
End With
End Sub

I put the first pagebreak before row 11. I used column A to find out the last
used row.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Thank you very much! The way doesn't matter until the code works and this
did. You made my day :=)

-Kate

"Dave Peterson" kirjoitti:
 
Back
Top