Counting lines per page

WhoCanDo

Board Regular
Joined
Dec 18, 2007
Messages
188
I am inserting page breaks to format my printing so I can get paragraphs onto a page (ie sets of info). I know how many lines there are on my printer but the other office printer has a different print area.

I can force Excel to print one page wide if I change the page setup to print 1 page wide and 10 pages long instead of 100% but then I will get a different number of lines per page than on my printer.

Fortunately my line heights are all the same so how do I count lines per page before formatting?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Have you tried clearing the pages(s) tall box (highlight the number in it and press Delete)? Then you won't need to insert any page breaks.
 
Upvote 0
Not following you Andrew.

If I clear the tall box then I may get infinite pages but that's not the problem.

If on one printer the print area is too wide for and A4 page then fitting to 1 wide and 10 tall will make it fit but the lines per page will change. That means that the when I expect the page to be eg. 21 lines it may change to 22 so my VBA needs to know that there are now 22 lines when calculating page breaks.

eg.

Tool:
a
b
c

Nut:
a
b
c

If the number of lines on my printer is 9 then all of the above will be on page 1 but on the other printer there are only 8 so I need a page break on line 6 (ie Nut:).
 
Upvote 0
If the print area starts at row 1 and there are only automatic horizontal page breaks:

MsgBox ActiveSheet.HPageBreaks(1).Location.Row - 1

will return the number of rows per printed page.
 
Upvote 0
ActiveSheet.HPageBreaks(1).Location.Row - 1

works well when there are more than one page to print but when there is less than one page it is "Subscript out of range"

The reason why I need to now how many lines fit on a page is because there are so many different printers in the office and each one has a different page length. I want to format the page so the page breaks are between titles. As soon as I add page breaks, the "Fit to" stops working so I need another solution.

Any other idea??
 
Upvote 0
OK, here's my latest bandaid until someone can suggest otherwise.

I have added a worksheet with items in column A, lines 1 to 500

ActiveSheet.HPageBreaks(1).Location.Row - 1 works with this static sheet so I will use it to get around the "Subscript out of range" error.

I would still appreciate any more ideas.

Thanks
 
Upvote 0

Forum statistics

Threads
1,215,056
Messages
6,122,907
Members
449,096
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top