MrExcel Publishing
Your One Stop for Excel Tips & Solutions

How can I determine where a page break is located?


Posted by Sue J. Stevens on August 19, 2001 10:00 AM

I have a excel file that is used to display financial data and the user provides narrative explanations for each line of data in the row directly below the financial data. I've set up a macro to automatically resize this row to fit the size of the narrative. When the report is printed, I don't want the financial data to get printed on one page while the narrative gets printed on another page. Is there a keep together function in VBA or Excel? Or, how can I determine where a page break is located thru VBA so I can write code to move it?


Posted by Andrew on August 19, 2001 12:42 PM

Go to View > Page Break Preview. You can then move the page breaks as you like. Page breaks are shown in blue. To return to the normal view go View > Normal.

Posted by Sue Stevens on August 23, 2001 6:12 PM

I know how to change a page break manually. I have picky, (lazy?) users who don't want to change any page breaks--they expect everything to work perfectly as if by magic. I need some VB code that will detect the location of an automatic page break and if it exists on a row between the sections I want to keep together then I'll add a manual page break above the section to keep together. I've got the code for everything except detecting the location of the auto page break.