difficult logic in trying to print multiple sheets to a single sheet that will control page breaks


Posted by Rees Macleod on May 20, 2000 7:39 PM

I am having a very difficult time in comming up with an idea to accomplish this:

I have made a template file in Excel 2000 that creates as many sheets as the user asks for and places a user defined number of rows of information and a user defined number of colums of information into each sheet. A typical quantity of information may take up around 2-18 Rows and 5-20 columns on each sheet and use 5-15 sheets. My problem is that I need to take all of the seperate sheets of information and place them all on one sheet that will print as many pages as needed for all the information. That in itself is not too difficult; however, It is esential that each sheets information remains together on one page. ie, I can't have a sheet that has 14 rows of information print 3 of those rows on page one, and then print the remaining 11 rows on the next page. In other words, Groups of information must all print on one page even if there is a large gap left at the bottom of a page. I am only having trouble with the rows. The columns are fine. Somehow, I must get a routine that looks ahead the specified number of rows, checks to see if the cells will cross over an automatic page break and if so, move to the beginning of the next page and place the next sheets information starting in that cell. Then continues to do this until it runs out of sheets.

My client does not want to have to manually set page breaks, and I am in desperate need of a solution. Any help anyone may have would be greatly appreciated.

Thanks,

Rees



Posted by Ivan Moala on May 21, 2000 12:19 AM

Hi Rees

How are you putting each sheets data onto the one sheet?
What ever way you are doing this it could be a matter of Naming these ranges and then in a print macro loop through each range ,setting the printArea / then print / Loop to next Prt Rg.

Use something like

ActiveWorkbook.Names.Add Name:="Prt1", RefersToR1C1:="=Sheet2!R1C1:R17C15"

to refer to your named ranges

To setup the print area then use something like;

Range(ActiveWorkbook.Names("prt1")).Select
ActiveSheet.PageSetup.PrintArea = Selection.Address

Then Loop through your named ranges.


Ivan


Ivan