J
Janis
THanks very much, this macro creates all the right page breaks except the
first one.
The first row dept doesn't need a pagebreak above it. So I tried to add an
ANd if to the conditional. And if it is the first row then don't do the
page break.
I don't know how to add a second condition to the first condition. Row 1 is
the header line, row 2 is the first department header. i don't want a page
break there.
Sub SSPPageBreak2()
Dim Rng As Range
Dim rngToSearch As Range
With ActiveSheet
Set rngToSearch = .Range(.Range("A1"), .Cells(Rows.Count, "A").End(xlUp))
For Each Rng In rngToSearch
If Rng.Interior.ColorIndex = 15 AND if rng <> .Range(r2) Then
ActiveSheet.HPageBreaks.Add before:=Rng
End If
Next Rng
End With
End Sub
first one.
The first row dept doesn't need a pagebreak above it. So I tried to add an
ANd if to the conditional. And if it is the first row then don't do the
page break.
I don't know how to add a second condition to the first condition. Row 1 is
the header line, row 2 is the first department header. i don't want a page
break there.
Sub SSPPageBreak2()
Dim Rng As Range
Dim rngToSearch As Range
With ActiveSheet
Set rngToSearch = .Range(.Range("A1"), .Cells(Rows.Count, "A").End(xlUp))
For Each Rng In rngToSearch
If Rng.Interior.ColorIndex = 15 AND if rng <> .Range(r2) Then
ActiveSheet.HPageBreaks.Add before:=Rng
End If
Next Rng
End With
End Sub