Results 1 to 20 of 20

VBA Code needed to automate page break(s) based on 3-column groupings

Threaded View

  1. #1
    Registered User
    Join Date
    04-22-2013
    Location
    Overland Park, KS
    MS-Off Ver
    Office 2010
    Posts
    12

    Post VBA Code needed to automate page break(s) based on 3-column groupings

    Hello. This is my first post, so hopefully I use the correct process.

    I have an Excel file (I use Excel 2010) with a series of 3-column groupings (Qty/Rate/Amount - see Sample file) which I would like to remain together in the event the content is large enough to cover multiple pages (i.e. I don't want Qty & Rate to be on page 1 and Amount for that same service to move over to page 2, for example.) I would also like to be able to insert the vertical page break(s) at the desired location so that the content of each page is large enough to be easily viewed once the file is saved as a PDF file. Based on the usual amount of content in these files, that amount to roughly 5-6 of these groupings per page.

    My thinking was to first remove all automatic page breaks. Then I would have the code count the number of occurrences of the word "Amount" and insert a manual vertical page break after the count reaches 5, at which time the count would be reset and the process would start over again until the next page break was inserted. This process would continue until the end of the file. Of course, I need also need a calculation to know when the file ends and that I can terminate the 5-count process described above.

    In the sample file, there is currently an automatic vertical page break between columns W and X. Using the scenario described above, I would want to end up with a manual page break between columns P and Q. [As an alternative, I am happy to move the automatic page breaks to the desired location, but am not sure how to do that either.] This would be the only page break in the example, since the next one is the end of the file.

    Any help would be appreciated. Thanks.
    Attached Files Attached Files
    Last edited by mkhammers; 07-01-2013 at 04:23 PM. Reason: clarified my summary of the issue

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