RedStarryGirl
New Member
- Joined
- Jan 26, 2009
- Messages
- 8
Hello,
I have a report in Excel 2007 which is just a pivot table controlled by a dropdown menu that users select a state from and it filters the pivot table. I already have code to dynamically set the print area for the report, as the number of rows varies dependent on the state selected. There are header rows repeated at the top, but what I need accomplished is to set a page break every 70 rows - not including the rows repeated at the top - so that a group of data is not split up. Is there a way to do this, given the Print Area? i.e. set a page break every 70 rows as long as the row is within the determined print area?
The code to set the print area:
I have a report in Excel 2007 which is just a pivot table controlled by a dropdown menu that users select a state from and it filters the pivot table. I already have code to dynamically set the print area for the report, as the number of rows varies dependent on the state selected. There are header rows repeated at the top, but what I need accomplished is to set a page break every 70 rows - not including the rows repeated at the top - so that a group of data is not split up. Is there a way to do this, given the Print Area? i.e. set a page break every 70 rows as long as the row is within the determined print area?
The code to set the print area:
Code:
Sub PrintArea()
Dim i As Integer
i = 14
Do While Cells(i, 24) <> ""
i = i + 1
Loop
With ActiveSheet.PageSetup
.PrintArea = "A14:Z" & i - 1
.PrintTitleRows = "$4:$13"
.PrintTitleColumns = ""
End With
End Sub