Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting pagebreaks in excel with vb

Status
Not open for further replies.

Koisti

Technical User
Aug 10, 2002
5
US
I have asked about this before, but the answer I got didn't fit what I need exactly, so I will reword the question. I use code to sort out orders in excel. Here is what the first 2 columns look like.
Order# Cust. #
9 W063868
9 W063868
9 W063868
10 W065372
10 W065372
10 W065372
10 W065372
Sometimes these only take up 2 rows and other times they take up to 6 rows. I want to put as many on one page as possible. How can I determine if the pagebreak splits an order in half and if it does then move the pagebreak up so that the order doesn't end up half on one page and half on the other page?
 


From vb this code would find page breaks but I do not remember how to set them but this should get you started.

For I = 1 To ActiveSheet.UsedRange.Rows.Count
If Rows(I).PageBreak = xlManual Or Rows(I).PageBreak = xlAutomatic Then
'this cell "I" is where there is a page break meaning
'the row before this one is where the last cell will
'printed and this cell "I" is a new page
DoEvents
Next Z

good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top