Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PageBreaks (2000)

    Ho to insert a PageBreaks (via code) only when in column A change value?
    In this case in line 97, 127, 164....
    note: The value in column A are already ordered.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: PageBreaks (2000)

    Try this macro:

    Sub InsertBreaks()
    Dim wsh As Worksheet
    Dim i As Integer
    Dim r As Long
    Dim m As Long
    Set wsh = ActiveSheet
    Application.ScreenUpdating = False
    wsh.ResetAllPageBreaks
    m = wsh.Cells(wsh.Rows.Count, 1).End(xlUp).Row
    For r = 3 To m
    If Not wsh.Cells(r, 1) = wsh.Cells(r - 1, 1) Then
    wsh.HPageBreaks.Add Before:=wsh.Cells(r, 1)
    End If
    Next r
    Application.ScreenUpdating = True
    End Sub

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PageBreaks (2000)

    Sorry me, work perfect!

Posting Permissions

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