+ Reply to Thread
Results 1 to 5 of 5

Inserting Page Breaks on relative Rows based on Data

Hybrid View

Tirren Inserting Page Breaks on... 10-29-2008, 06:56 PM
shg Sub x() Dim iRow As... 10-29-2008, 07:08 PM
Tirren Instead of .EntireRow.Insert... 10-29-2008, 07:30 PM
shg Ah, page breaks: Sub x() ... 10-29-2008, 07:34 PM
Tirren OMG your just awesome! 10-29-2008, 07:38 PM
  1. #1
    Registered User
    Join Date
    07-02-2008
    Location
    Fort Worth, TX
    Posts
    99

    Inserting Page Breaks on relative Rows based on Data

    Each week I format a report that I receive that lists every product a particular employee closed. Its a list of each employee, the product and date. I'll have about 20-30 lines for each employee. I can easily sort by the employee name to have a nice list.

    From here what I do is use a forumla to mark where each employee's name changes, then filter by that changed line and insert page breaks for each of these lines.

    Is there a way to macro this to save me time, having 270 employees takes alot of time still, because thats 270 manually inserted page breaks.
    Attached Files Attached Files
    Last edited by Tirren; 10-29-2008 at 07:39 PM. Reason: problem resolved

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Sub x()
        Dim iRow    As Long
    
        iRow = 3
        Do
            With Cells(iRow, "C")
                If IsEmpty(.Value) Then Exit Do
                If .Offset(-1).Value <> .Value Then
                    .EntireRow.Insert
                    iRow = iRow + 2
                Else
                    iRow = iRow + 1
                End If
            End With
        Loop
    End Sub
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    07-02-2008
    Location
    Fort Worth, TX
    Posts
    99
    Instead of .EntireRow.Insert

    How do I change this to Insert pagebreak here?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Ah, page breaks:
    Sub x()
        Dim cell    As Excel.Range
    
        ActiveSheet.ResetAllPageBreaks
        For Each cell In Range("C3", Range("C3").End(xlDown))
            If cell.Value <> cell.Offset(-1).Value Then
                ActiveSheet.HPageBreaks.Add before:=cell
            End If
        Next cell
    End Sub

  5. #5
    Registered User
    Join Date
    07-02-2008
    Location
    Fort Worth, TX
    Posts
    99
    OMG your just awesome!

+ 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