SimonGeoghegan
Board Regular
- Joined
- Nov 5, 2013
- Messages
- 68
Hi All,
I have the following code which I believe should add page breaks at every 20th line of a worksheet. However, this does not seem to be applying when I check both the "Print Preview" screen or the "Page Break Preview".
I effectively had an action plan which could, over time, become very large, and therefore I want the user to be able to print this off to show 20 lines per page, alongside rows 1-6 which will be repeated.
The screenshot hopefully shows both the code as I'm stepping through, and also the lack of page breaks. I also show the "Row_Index" in the immediate window to show its currently set to line 26.
I assume I am missing something, but could someone possibly point me in the right direction?
Regards,
Simon
I have the following code which I believe should add page breaks at every 20th line of a worksheet. However, this does not seem to be applying when I check both the "Print Preview" screen or the "Page Break Preview".
VBA Code:
Dim Row_Index As Long
Dim RW As Long
RW = 20
With ActiveSheet
.ResetAllPageBreaks
For Row_Index = RW + 6 To LastRow2 Step RW
.HPageBreaks.Add Before:=.Cells(Row_Index, 1)
Next
End With
I effectively had an action plan which could, over time, become very large, and therefore I want the user to be able to print this off to show 20 lines per page, alongside rows 1-6 which will be repeated.
The screenshot hopefully shows both the code as I'm stepping through, and also the lack of page breaks. I also show the "Row_Index" in the immediate window to show its currently set to line 26.
I assume I am missing something, but could someone possibly point me in the right direction?
Regards,
Simon