Results 1 to 2 of 2

Insert Page Break in Template based on changing data in column B

Threaded View

  1. #1
    Registered User
    Join Date
    10-08-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    1

    Insert Page Break in Template based on changing data in column B

    I have searched through all the threads and can't seem to get the VB code to work right. I have Excel 2010. I have a template where rows 1-4 are the header rows. The data starts at row 5. I need to page break when the data in Column B changes starting on row 5 and looping until it reaches the last row. On a side note, I would like this code to work for all sheets in the worksheet if possible so I don't have to run it multiple times. If not, no big deal. Thanks in advance.

    I many need to add more info. My data looks something like this:

    Errors Assigned
    1/1/2013 - 10/1/2013

    MANAGER USERID NAME ERRCD COUNT
    WALT TEST1 MICKY 1 5
    WALT TEST1 MICKY 2 1
    WALT TEST1 MICKY 3 4
    WALT TEST1 MICKY 3 6
    WALT TEST1 MICKY 4 2
    WALT TEST2 DONALD 2 1
    WALT TEST2 DONALD 2 1
    WALT TEST2 DONALD 3 1
    WALT TEST2 DONALD 4 6
    WALT TEST3 GOOFY 1 5
    WALT TEST3 GOOFY 1 5
    WALT TEST3 GOOFY 2 6
    WALT TEST3 GOOFY 4 3
    WALT TEST3 GOOFY 5 2
    WALT TEST3 GOOFY 5 5
    WALT TEST3 GOOFY 5 1
    WALT TEST3 GOOFY 6 1
    WALT TEST3 GOOFY 6 1
    WALT TEST3 GOOFY 6 1
    WALT TEST3 GOOFY 6 1


    I have tried the below but it doesn't work. I am trying to add a page break every time Column B changes to a different name.

    Sub pagebrk()
    col = 2 ' what ever column you want to measure.
    LastRw = ActiveSheet.UsedRange.Rows.Count
    For x = 2 To LastRw
    If Cells(x, col) <> Cells(x - 1, col) Then
    ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(x, col)
    End If
    Next
    End Sub
    Last edited by Shadow55; 10-09-2013 at 03:40 PM. Reason: Additional information

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Code needed to automate page break(s) based on 3-column groupings
    By mkhammers in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 07-10-2013, 05:57 PM
  2. Need Page Break on Change in Data in a Column
    By RGFalls in forum Excel General
    Replies: 1
    Last Post: 07-08-2013, 07:57 PM
  3. VBA to insert page break when column cell border colour changes?
    By JungleJme in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2013, 04:36 AM
  4. Macro to Insert Page Break Where "A" Column Changes Value
    By theoak in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-07-2013, 05:45 AM
  5. Counting cells with data into row above page break in column x, ever changing.
    By jsalgado in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2011, 02:57 PM

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