Results 1 to 3 of 3

VBA to insert page breaks

Threaded View

jordan2322 VBA to insert page breaks 09-27-2012, 10:39 PM
Leith Ross Re: VBA to insert page breaks 09-27-2012, 11:03 PM
jordan2322 Re: VBA to insert page breaks 09-27-2012, 11:27 PM
  1. #1
    Forum Contributor
    Join Date
    11-16-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    405

    Question VBA to insert page breaks

    Hi there,

    I am using the following code courtesy of xladept @: http://www.excelforum.com/excel-prog...int-macro.html

    Sub SetPA():
    Dim i As Integer
    Dim t As Integer
    Dim PA As String
    
    t = 2
    i = Range("C" & Rows.Count).End(xlUp).Row: PA = "$A$1:$J" & i
    t = Int(i / 50) + 1
    With ActiveSheet.PageSetup
             .PrintArea = PA: .Orientation = xlPortrait
            .CenterHorizontally = True: .Zoom = False
            .FitToPagesWide = 1: .FitToPagesTall = t
    End With: End Sub
    This macro simply inserts page breaks into the active worksheet.

    I need to be able to change the position of these page breaks such that my sheet prints more neatly!

    1. The current position of all the horizontal page breaks needs to be adjusted either up or down depending on the following.

    From the Horizontal Page break Row - Find what the Row number is of the next cell ABOVE the page break row & in Column 2, thats cell.value is like "*Crew*"
    Likewise do the same for BELOW who's cell value is also like "*Crew*"

    Determine which of these is the closer to the page break, and re-adjust the page break to the position of the found cell/row.

    This needs to be done for all the Page breaks on the worksheet

    Some help on this one would be really appreciated!

    Regards
    Jordan
    Last edited by jordan2322; 09-27-2012 at 10:40 PM. Reason: added line: This needs to be done for all the Page breaks on the worksheet

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