Limit to number of pagebreaks???

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
 
D

Dave Peterson

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.
 

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