View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default How to insert page break after every 10 rows?

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

kativa wrote:

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.


--

Dave Peterson