#1   Report Post  
Dottie
 
Posts: n/a
Default 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   Report Post  
Trevor Shuttleworth
 
Posts: n/a
Default

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   Report Post  
Myrna Larson
 
Posts: n/a
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using macro for page break Sara Excel Discussion (Misc queries) 2 January 13th 05 10:29 PM
page break preview lein Excel Discussion (Misc queries) 0 December 23rd 04 11:55 AM
Is there a way to get an auto page break as data changes in Excel. george_visalia Excel Discussion (Misc queries) 2 December 16th 04 01:22 AM
slow page break previews chriscrisco Excel Discussion (Misc queries) 1 December 13th 04 09:06 PM
Page break macro lehigh46 Excel Worksheet Functions 2 November 17th 04 03:00 AM


All times are GMT +1. The time now is 11:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"