+ Reply to Thread
Results 1 to 4 of 4

VBA to stop automatic page breaks from occurring in a range of 4 rows

  1. #1
    Registered User
    Join Date
    02-11-2016
    Location
    Wisconsin
    MS-Off Ver
    07-360
    Posts
    53

    VBA to stop automatic page breaks from occurring in a range of 4 rows

    I need to stop page breaks from occurring within a group of 4 rows, but do not want them to always occur before them. This is a signature line at the end of a report and we would like the signatures to stay together. As the row number changes with the amount of data before it, I have selected the group of cells in question and titled them “Signature”. Currently there are no manual page breaks on the worksheet. I have added the code that I am using to format the document and print in case it helps. Thanks in advance!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA to stop automatic page breaks from occurring in a range of 4 rows

    Hi there,

    Define your signature block as a Named Range called "tblSignatureBlock", and see if the following code does what you need:

    It uses the following code:

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your own requirements.

    The code should be inserted in the ThisWorkbook VBA CodeModule of your workbook, not in a standard VBA CodeModule.


    The code works by checking whether or not an automatic PageBreak occurs within the Signature Block, and if so, inserts a temporary manual PageBreak immediately before the Signature Block, performs the Print operation, and then removes the temporary PageBreak. Inserting and then removing the temporary PageBreak are ignored as "changes" as far as the "Saved" state of the workbook is concerned.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    02-11-2016
    Location
    Wisconsin
    MS-Off Ver
    07-360
    Posts
    53

    Re: VBA to stop automatic page breaks from occurring in a range of 4 rows

    Thanks for your help, the time and the writeup on how it works! This works great!

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: VBA to stop automatic page breaks from occurring in a range of 4 rows

    Hi again,

    Many thanks for your feedback and also for the Reputation increase - much appreciated

    You're very welcome - glad I was able to help.

    Best regards,

    Greg M

+ 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. Too Many Automatic Page Breaks
    By dheptig in forum Excel General
    Replies: 2
    Last Post: 03-10-2019, 11:59 AM
  2. Automatic Page Breaks
    By BADebbie in forum Excel General
    Replies: 4
    Last Post: 07-05-2015, 06:04 PM
  3. Prevent automatic page breaks?
    By proepert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2010, 07:08 AM
  4. Moving Automatic Page Breaks
    By Andre1075 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-03-2009, 03:07 AM
  5. [SOLVED] Automatic Page Breaks
    By Cici in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-23-2006, 05:00 PM
  6. [SOLVED] Automatic Page Breaks
    By Ron in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-05-2006, 09:10 AM
  7. [SOLVED] find automatic page breaks
    By Reason in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-15-2005, 01:06 AM

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