I have a report that does not have uniform columns or rows, but where the phrase TOTAL: appears, I have created a new column A w/ a certain value (the date) (using an If statement).
Where the date appears in column A I need to create a page break on the row BELOW the cell where the date in my new column A appears.
I have the following macro, which is sort of working, but it's creating a page break both ABOVE and BELOW the row so I need to eliminate the page break that is occurring in the row ABOVE the date.
Is this possible?
Here's the macro that I'm using:
Sub PageBreak()
'UpdatebyExtendOffice20181101
Dim xSRg As Range
Dim xRg As Range
On Error Resume Next
Set xSRg = Application.InputBox("Select key column:", "Kutools for Excel", xTxt, , , , , 8)
If xSRg Is Nothing Then Exit Sub
Application.ScreenUpdating = False
For Each xRg In xSRg
ActiveSheet.Rows(xRg.Row).PageBreak = xlPageBreakNone
If xRg.Value <> xRg.Offset(-1, 0).Value Then
ActiveSheet.Rows(xRg.Row).PageBreak = xlPageBreakManual
End If
Next xRg
Application.ScreenUpdating = True
End Sub
Where the date appears in column A I need to create a page break on the row BELOW the cell where the date in my new column A appears.
I have the following macro, which is sort of working, but it's creating a page break both ABOVE and BELOW the row so I need to eliminate the page break that is occurring in the row ABOVE the date.
Is this possible?
Here's the macro that I'm using:
Sub PageBreak()
'UpdatebyExtendOffice20181101
Dim xSRg As Range
Dim xRg As Range
On Error Resume Next
Set xSRg = Application.InputBox("Select key column:", "Kutools for Excel", xTxt, , , , , 8)
If xSRg Is Nothing Then Exit Sub
Application.ScreenUpdating = False
For Each xRg In xSRg
ActiveSheet.Rows(xRg.Row).PageBreak = xlPageBreakNone
If xRg.Value <> xRg.Offset(-1, 0).Value Then
ActiveSheet.Rows(xRg.Row).PageBreak = xlPageBreakManual
End If
Next xRg
Application.ScreenUpdating = True
End Sub