+ Reply to Thread
Results 1 to 3 of 3

Hard Page Break

  1. #1
    Dottie
    Guest

    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 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.

  2. #2
    Trevor Shuttleworth
    Guest

    Re: Hard Page Break

    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" <[email protected]> wrote in message
    news:[email protected]...
    >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.




  3. #3
    Myrna Larson
    Guest

    Re: Hard Page Break

    If you want the break before the line, remove the "+ 1".


    On Wed, 12 Jan 2005 12:57:02 -0800, Dottie <[email protected]>
    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 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.



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1