Consulting

Results 1 to 3 of 3

Thread: Solved: Page break at each change in customer

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Solved: Page break at each change in customer

    This is the code I am trying:

    [VBA]For i = finalRow To 2 Step -1
    If Cells(i, "A") = Cells(i, "A").Offset(-1, 0) Then
    ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(i, "A")
    Else
    End If
    Next[/VBA]

    It isn't giving me an error but it isn't inserting the page break either.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It puts thousands in for me, you are testing wrongly.

    If you get none, what is in finalrow?

    The code should be

    [vba]

    For i = finalrow To 2 Step -1
    If Cells(i, "A").Value <> Cells(i - 1, "A").Value Then
    ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(i, "A")
    End If
    Next
    [/vba]

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Thank you that worked perfectly

Posting Permissions

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