+ Reply to Thread
Results 1 to 4 of 4

How do I automatically insert a page break?

Hybrid View

  1. #1
    Registered User
    Join Date
    07-12-2010
    Location
    United States
    MS-Off Ver
    Excel Office 365
    Posts
    26

    Question How do I automatically insert a page break?

    Greetings Everyone:

    I work for a newspaper that delivers thousands of papers each delivery cycle. Some addresses have special handling instructions that the contractors have to have printed and handed to them. Those instructions are put into an Excel sheet.......one address per row. Is there a macro that can be written to automatically insert a page break for each row? In the attached example, I only used a few addresses for example purposes. In real life, the list can be several hundred addresses long each day. Currently I manually insert a page break, which can take a VERY long time to complete depending on the number of addresses.

    I do not make the sheet either....it comes from another department.

    Thanks in advance for the input.

    I have attached an example of the sheet.
    Attached Files Attached Files
    Last edited by verifier; 01-06-2014 at 05:58 PM.

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: How do I automatically insert a page break?

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    
    '
    Dim rmax, r
    rmax = Sheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row
    
    
    r = 6
    While r < rmax
    
        Rows(r & ":" & r).Select
        ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
    r = r + 1
    Wend
    
    End Sub

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: How do I automatically insert a page break?

    Sub Macro1()
    
    Dim count
    For count = 2 To Range("A" & Rows.count).End(xlUp).Row
    ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Range("A" & count)
    Next
    End Sub

  4. #4
    Registered User
    Join Date
    07-12-2010
    Location
    United States
    MS-Off Ver
    Excel Office 365
    Posts
    26

    Re: How do I automatically insert a page break?

    Quote Originally Posted by yudlugar View Post
    Sub Macro1()
    
    Dim count
    For count = 2 To Range("A" & Rows.count).End(xlUp).Row
    ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Range("A" & count)
    Next
    End Sub
    Tried this one and it works every time. Thank you!!

    This has made the chore much, much faster.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Insert blank row, sum and insert page break macro
    By kim5012 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-06-2012, 01:46 AM
  2. insert page header after page break
    By dgkindy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-17-2009, 10:35 AM
  3. [SOLVED] Automatically insert page break every 6 rows in excel doc
    By Icetea in forum Excel General
    Replies: 1
    Last Post: 10-10-2005, 07:05 AM
  4. [SOLVED] automatically insert row at each page break
    By Row in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-09-2005, 12:05 PM
  5. Insert Page Break
    By Don in forum Excel General
    Replies: 3
    Last Post: 06-09-2005, 04:05 PM

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