kylegjordan
Technical User
I'm trying to add page breaks above rows meeting a certain condition and are identified by a for-next loop with an if-then statement that confirms the. This means that the "worksheets.rows().pagebreak = xlpagebreakmanual" uses a variable for the rows argument (code below). Not only is the pagebreak not being set, but the worksheet insists on setting it's own automatic breaks that won't remove when I set code to do so. Please let me know if you see where I'm going wrong, or if you have a different way of approaching this.
Worksheets(1).Rows(58).PageBreak = xlPageBreakNone
Worksheets(1).Columns("I"
.PageBreak = xlPageBreakManual
For pgb = 1 To 75
If Worksheets(1).Cells(pgb, 8).Value = "cell end" Then
Worksheets(1).Rows(pgb).PageBreak = xlPageBreakManual
End If
Exit For
Next pgb
Thanks.
kj
Worksheets(1).Rows(58).PageBreak = xlPageBreakNone
Worksheets(1).Columns("I"
For pgb = 1 To 75
If Worksheets(1).Cells(pgb, 8).Value = "cell end" Then
Worksheets(1).Rows(pgb).PageBreak = xlPageBreakManual
End If
Exit For
Next pgb
Thanks.
kj