PDA

View Full Version : Solved: Page break at each change in customer



Djblois
01-25-2007, 12:44 PM
This is the code I am trying:

For i = finalRow To 2 Step -1
If Cells(i, "A") = Cells(i, "A").Offset(-1, 0) Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(i, "A")
Else
End If
Next

It isn't giving me an error but it isn't inserting the page break either.

Bob Phillips
01-25-2007, 12:51 PM
It puts thousands in for me, you are testing wrongly.

If you get none, what is in finalrow?

The code should be



For i = finalrow To 2 Step -1
If Cells(i, "A").Value <> Cells(i - 1, "A").Value Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(i, "A")
End If
Next

Djblois
01-25-2007, 12:58 PM
Thank you that worked perfectly