Hard Page Break

D

Dottie

I found this macro in this newsgroup, but it is putting the page breaks after
not before the "Results" which in my case is going to be 1/12/2005.

Option Explicit
Sub insert_pagebreak()
Dim lastrow As Long
Dim row_index As Long

lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index, "A").Value ="Result" then
ActiveSheet.HPageBreaks.Add Before:= _
Cells(row_index + 1, "A")
End If
Next
End Sub

Sub remove_them()
ActiveSheet.ResetAllPageBreaks
End Sub

Thank you for all your help in advance.
 
T

Trevor Shuttleworth

Dottie

perhaps not very helpful, but your code works for me unchanged. It inserts
a page break after the line with "Result" in column A.

Regards

Trevor
 

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

Similar Threads


Top