Consulting

Results 1 to 3 of 3

Thread: Solved: page breaks

  1. #1
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location

    Solved: page breaks

    Hello,

    I am writing a print macro in an excel workbook.

    However the amount of information can grow and contract so I am trying to write some code to build in page breaks.

    If I was doing this manually I would view it in page break mode and move the page breaks up and down depending if certain lines straddle a page break or not.

    If I record this macro it simply puts the page breaks where I have set them in VBA code.

    Is there a way to see if a paragraph or set of lines in a worksheet straddle where a page break would be and then move the breaks as necessary.

    This seems like a big ask but it would be great if it could be cracked

    Thanks
    Phil

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    When you say straddle, do you mean that if there is a gap of one row after a block of say 10 solid rows this is where you would like the break?

    You could post a workbook with some dummy data in and place some borders where you would like the page breaks to be.
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  3. #3
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location

    Page Breaks

    Hi,

    an example workbook is attached.

    in sheet 1 I'd want the automatic page break inserted by excel (in page break preview) to be moved up to line 37 and in sheet 2 I want it moved up to line 40

    the issue is from one day to the next I dont know where the paragraphs will lie so I would want a way to determine programatically where excel is putting the page breaks and move them to the top of the paragraph if it is cutting one in half

    hope this is clear!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •