Limit to number of pagebreaks???

  • Thread starter Thread starter andy
  • Start date Start date
A

andy

A kind person helped me by supplying code for a macro to
insert a page break based on the changing of a value in a
column. It will work on a limited amount of data (~ 3,000
records) but not on my entire file (~10,000 records). Is
there a limit to the amount of pagebreaks you can insert?
This is the code, perhaps someone has another suggestion:

Sub InsertPagebreak()
lastrow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
For rowindex = lastrow - 1 To 10 Step -1
If Cells(rowindex, "B").Value <> "" Then
If IsNumeric(Cells(rowindex, "B").Value) Then
If Cells(rowindex, "B").Value <> _
Cells(rowindex + 1, "B").Value Then
ActiveSheet.HPageBreaks.Add Before:= _
Cells(rowindex + 1, "B")
End If
End If
End If
Next
End Sub

Thank you in advance
God bless you
 
When I ran this against some test data, I got a message back:

....A worksheet can contain up to 1026 horizontal page breaks.

Do you really need to print more than 1000 sheets?

If you do, maybe you can put some of the data on different sheets and add less
than 1026 page breaks on each of those sheets.
 
Back
Top