I'd like to put a page break in the attached worksheet. I have the below macro that I thought I used last time, but when I run it now, it puts a page break after changes in all the data and I ended up getting over 900 pages on my 500+ line spreadsheet.
What I would like to do, is after each "total" in column B, have that be the end of the page and have a new page start. In the attached example sheet, I would like page 2 to start on line 26, and page 3 to start on line 38.
This is my current macro, hopefully I can just modify it a bit.
******************************************************************************************
Sub AddPageBreaks()
Dim R As Long
Dim Rng As Range
Dim RngEnd As Range
Dim Wks As Worksheet
Set Wks = ActiveSheet
Set Rng = Wks.Range("B2")
Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp)
If RngEnd.Row < Rng.Row Then Exit Sub Else Set Rng = Wks.Range(Rng, RngEnd)
For R = 1 To Rng.Rows.Count - 1
If Rng.Item(R, 1) <> Rng.Item(R + 1, 1) Then
Rng.Item(R + 1, 1).PageBreak = xlPageBreakManual
End If
Next R
End Sub
******************************************************************************************
Report - Change in Column Value.xls
Bookmarks