+ Reply to Thread
Results 1 to 8 of 8

Creating a Page Break Macro for Dynamic Data

  1. #1
    Registered User
    Join Date
    11-09-2017
    Location
    Chicago
    MS-Off Ver
    Office 2016
    Posts
    2

    Creating a Page Break Macro for Dynamic Data

    Hello!

    I am creating financial reports (populated by uploaded data) and would like to write a macro to insert a page break; however, where the page break should be can change month to month. Is there a way to write a code in such a way that it will not break a 5-line grouping up?

    For example, all my segments are:

    Header 1
    Revenue
    Expense
    Net Income
    {blank line}

    At different months, the automatic page break may cut between Revenue and Expense or Expense and Net Income, all depending on how many segments were active that month. I need the macro to read these groupings and if a segment is divided, insert a page break prior to the header.

    Everything I can find either sets the page break at a certain word or after a certain number of lines which I cannot utilize for this issue. Is this macro possible?


    Sample Picture.png

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Creating a Page Break Macro for Dynamic Data

    What is the determinant of breaking the page, some signature e.g. "PB" in the column next to or something else, or page can be broken anywhere, but not across the segment ?
    It would be better if it was a table/array.

  3. #3
    Valued Forum Contributor
    Join Date
    12-22-2015
    Location
    HK
    MS-Off Ver
    2010
    Posts
    532

    Re: Creating a Page Break Macro for Dynamic Data

    Try this:
    Please Login or Register  to view this content.
    Last edited by ikboy; 11-10-2017 at 04:53 AM.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,523

    Re: Creating a Page Break Macro for Dynamic Data

    Attach a file that people can work with. I find it very difficult to run code on a picture. Mention the maximum amount of rows you want for each print page and if you have any print titles or not.
    https://support.microsoft.com/en-gb/kb/210663
    I don't know if the problem mentioned in above article has been fixed or not.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,523

    Re: Creating a Page Break Macro for Dynamic Data

    Forgot to ask.
    Why do you need Page Breaks. You can print ranges without setting page breaks.
    I assume that you want to print these areas.

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,523

    Re: Creating a Page Break Macro for Dynamic Data

    So which code did you go with?

  7. #7
    Registered User
    Join Date
    11-09-2017
    Location
    Chicago
    MS-Off Ver
    Office 2016
    Posts
    2

    Re: Creating a Page Break Macro for Dynamic Data

    Thank you all for your input - after testing, we decided to go a different route due to the nature of the data warehouse.

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,523

    Re: Creating a Page Break Macro for Dynamic Data

    Thank you for the update. Good luck and if you need any Excel Help, you know where to come to.

+ 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. VBA Dynamic Page Break to retain a range when printing
    By drewmey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-24-2015, 10:08 AM
  2. [SOLVED] VBA/Macro to detect a heading at the bottom of a page and create a page break
    By jdodz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-22-2014, 07:16 PM
  3. Find First match value and add page break, findnext value and add page break
    By dwx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-20-2013, 12:58 PM
  4. Dynamic Page Break: Column Widths
    By dongman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-10-2008, 06:23 PM
  5. [SOLVED] Creating Page Break in Print Statement
    By Nigel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-02-2005, 07:45 AM
  6. printing - creating new files on each page break
    By Tere Gardner in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-04-2005, 05:06 PM
  7. Page Break Preview Page Number as Data
    By Neal Zimm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-02-2005, 08:06 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