View Full Version : Solved: page breaks

11-10-2008, 07:11 AM

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


11-10-2008, 09:41 AM
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.

11-13-2008, 07:44 AM

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!!!