+ Reply to Thread
Results 1 to 3 of 3

Page Breaks Macro

  1. #1
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162

    Page Breaks Macro

    Hi!
    I would like to clear all page breaks and set a page break between each change in rows in column A example, I want a page break between row 2 and 3. I'll set row 1 to repeat at the top of the printed page.
    A B
    1 Dept. Name
    2 02 Jack
    3 02 Bill
    4 03 Bob

    How would the code look for a task like this?

    As always, any help or direction is greatly appreciated!
    And thanks for your time!!

  2. #2
    Gary L Brown
    Guest

    RE: Page Breaks Macro

    Dim dblRow As Double

    ActiveSheet.ResetAllPageBreaks

    ActiveSheet.PageSetup.PrintTitleRows = "$1:$1"

    Range("B2").Select

    Do
    dblRow = dblRow + 1
    If Len(ActiveCell.Offset(dblRow, 0).Value) <> 0 Then
    If ActiveCell.Offset(dblRow, 0).Value <> _
    ActiveCell.Offset(dblRow - 1, 0).Value Then
    ActiveWindow.SelectedSheets.HPageBreaks.Add _
    Before:=ActiveCell.Offset(dblRow, 0)
    End If
    Else
    Exit Sub
    End If
    Loop


    HTH,
    --
    Gary Brown
    gary_brown@ge_NOSPAM.com
    If this post was helpful, please click the ''Yes'' button next to ''Was this
    Post Helpfull to you?''.


    "Brian Matlack" wrote:

    >
    > Hi!
    > I would like to clear all page breaks and set a page break between each
    > change in rows in column A example, I want a page break between row 2
    > and 3. I'll set row 1 to repeat at the top of the printed page.
    > A B
    > 1 Dept. Name
    > 2 02 Jack
    > 3 02 Bill
    > 4 03 Bob
    >
    > How would the code look for a task like this?
    >
    > As always, any help or direction is greatly appreciated!
    > And thanks for your time!!
    >
    >
    > --
    > Brian Matlack
    > ------------------------------------------------------------------------
    > Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508
    > View this thread: http://www.excelforum.com/showthread...hreadid=552437
    >
    >


  3. #3
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162
    Thanks Gary!!
    I'll study it to figure-out how but it works great!!

+ 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