Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Printing pairs of rows

66 views
Skip to first unread message

Otto Moehrbach

unread,
Feb 4, 2002, 11:49:28 AM2/4/02
to

I need to print a bunch of data. I first arrange the data like I want it
to appear in print. This groups my data in pairs of rows. IOW each pair of
rows represents one group. I need to force page breaks such that no group
will be split up between two pages. I know how to determine odd/even and
insert page breaks. What I don't know is how do I determine the row number
of the last row Excel is going to print on the first page? On the second
page? Etc.?
Thanks for any help you can provide. Otto

Ronald Dodge

unread,
Feb 4, 2002, 12:27:48 PM2/4/02
to
Try using this particular code.

Range("A65536").End(xlUp).Row

This code returns the last row in Column "A" has data making the assumption
cell A65536 is empty.

Ronald Dodge
Production Statistician
Master MOUS 2000

"Otto Moehrbach" <ot...@worldnet.att.net> wrote in message
news:OUpDxwZrBHA.1744@tkmsftngp07...

Otto Moehrbach

unread,
Feb 4, 2002, 12:49:36 PM2/4/02
to
Ronald
Thanks for the prompt reply, but I think you misunderstood my question.
I don't want to know the row number of the last row of data. I want to know
the row number of the last row of data that Excel is going to print on the
first page of the printout, on the second page, on the third page, etc.
That way I can insert page breaks, programmatically, to not split any group
of two rows between two pages. Thanks again. Otto
"Ronald Dodge" <ronald...@cskcorp.com> wrote in message
news:#952IFarBHA.680@tkmsftngp04...

Ronald Dodge

unread,
Feb 4, 2002, 1:33:30 PM2/4/02
to
I did a little additional looking in the help files. You may find this a
bit of help.

For Each pb in Worksheets(1).HPageBreaks
ProposedHPageBreakRow = pb.Location.Row
If <condition to see if this row is breaking up the group> Then
'code to determine the first row of the group that is being split up
otherwise
pb.Location = Worksheets(1).Range(<The cell reference of the first
row of the supposed splitup group otherwise>)
End If
Next

Maybe this will be of more help to you. this code will detect both
automatic and manual horizonal page breaks.

Ronald Dodge
Production Statistician
Master MOUS 2000

P.S. had to do some digging in the help files on this one.

"Otto Moehrbach" <ot...@worldnet.att.net> wrote in message

news:eGsxVSarBHA.1964@tkmsftngp07...

Otto Moehrbach

unread,
Feb 4, 2002, 1:50:59 PM2/4/02
to
Ronald
Thanks again for your help. I'll work on this and see what happens.

Otto
"Ronald Dodge" <ronald...@cskcorp.com> wrote in message
news:OPG42parBHA.2452@tkmsftngp03...

David McRitchie

unread,
Feb 4, 2002, 2:13:43 PM2/4/02
to
Hi Ronald,
That's a good find, example and factoid. The easiest solution
would be to adjust the margins in Print Preview. But this little
skeletal code from HELP provides the means to take care of
number of rows repeated at the top, rows of different heights
and whatever else you might have, without future manual
intervention except to run a macro. Simplifies coding for
1) 2 rows in a group as Otto requested
2) multiple rows in a group or
3) simply make sure that the last line on a printed page
is not the beginning of group which is probably closer
to what most people want (also cover two rows per group).

Likely column A has something that determines what a group is
rather than relying on which row numbers would have a new
group.

At the beginning of code Otto would probably want to remove
all preexisting manual pages breaks.
ActiveSheet.ResetAllPageBreaks

HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Macros: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm


"Ronald Dodge" <ronald...@cskcorp.com> wrote in message news:OPG42parBHA.2452@tkmsftngp03...

0 new messages