Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Hard Page Break
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 Befo= _ 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. |
#2
|
|||
|
|||
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 "Dottie" wrote in message ... 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 Befo= _ 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. |
#3
|
|||
|
|||
If you want the break before the line, remove the "+ 1".
On Wed, 12 Jan 2005 12:57:02 -0800, Dottie wrote: 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 Befo= _ 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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using macro for page break | Excel Discussion (Misc queries) | |||
page break preview | Excel Discussion (Misc queries) | |||
Is there a way to get an auto page break as data changes in Excel. | Excel Discussion (Misc queries) | |||
slow page break previews | Excel Discussion (Misc queries) | |||
Page break macro | Excel Worksheet Functions |