Announcement

Collapse
No announcement yet.

Vertical Page Breaks Every X Columns

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Vertical Page Breaks Every X Columns



    How can I insert vertical page breaks at every 35 columns by a macro when the number of columns in the worksheet is variable?

    There are examples about inserting page breaks at a specified number of rows but I could nor convert them to vertical page breaks.

    I'll be very very very glad for your help.

  • #2
    Re: Insertin Page Breaks Every 35 Columns

    Try :
    Code:
    Sub test()
        Dim i As Integer
        For i = 35 To Cells.Find("*", [A1], xlValues, , xlByColumns, xlPrevious).Column Step 35
            ActiveSheet.Columns(i).PageBreak = xlPageBreakManual
        Next i
    End Sub
    Daniel
    Regards.
    Daniel

    Comment


    • #3
      Re: Insertin Page Breaks Every 35 Columns

      I am really glad that your help has rescued me from a great burden.... thanks!!

      Comment


      • #4


        I guess I can use the same method to insert horizontal and vertical page breaks, right?

        I have a situation where I need to insert a vertical page break at column T, and then a horizontal page break at every 40 rows.

        I tried this:

        Sub PageBreak()

        Dim i As Integer

        For i = 41 To Cells.Find("*", [A1], xlValues, , xlByRows, xlPrevious).Row Step 41

        ActiveSheet.Rows(i).PageBreak = xlPageBreakManual

        Next i

        End Sub


        ...and got the horizontal breaks - how do I insert the vertical break at column T in the same code?

        Comment

        Working...
        X