doesn't compile, thinks HPageBreak method is a variable

J

Janis

this macro doesn't compile on the HPageBreak. It thinks it is a variable not
a method?
What I'm trying to do is force a page break above every department header
row. Every lite gray row is a department header. I want a page break at the
end of every department range so this should work.


Sub SSPPageBreak2()
Dim Rng As Range
Dim rngToSearch As Range
With ActiveSheet
Set rngToSearch = .Range(.Range("A1"), .Cells(Rows.Count, "A").End(xlUp))
End With
For Each Rng In rngToSearch
If Rng.Interior.ColorIndex = 15 Then HPageBreaks.Add before:=.Range
Next Rng
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top