How to set page breaks in equal intervals?

  • Thread starter Thread starter Lana
  • Start date Start date
Hi
you may try the following macros (change the step factor accroding to
your needs):
Option Explicit
Sub insert_pagebreak()
Dim lastrow As Long
Dim row_index As Long

lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For row_index = 1 to lastrow step 20
ActiveSheet.HPageBreaks.Add Before:= _
Cells(row_index + 1, "A")
Next
End Sub

Sub remove_them()
ActiveSheet.ResetAllPageBreaks
End Sub
 
Thanks Frank,

it worked, I just made the first insertion row equal to the step!

thanks a lot.

Have a nice weekend
 

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

Back
Top