Printing rows in 1 block

S

Sam Vanderstraeten

Hi,

I have an Excel-file with much worksheets (+/- 200). Every worksheet
contains some or much datarows (sometimes 2 rows, sometimes 5 pages of
rows).
At the bottom of every worksheet (not every page), I want to print a grid of
about 7 to 10 rows with some data in.
The porblem I have now is...
1. When I print a worksheet of 2 rows data + grid, everything fits on one
page = OK
2. When I print a page of f.e. 20 rows data + grid, the data and the first 3
lines of my grid are on page 1, the other 5 lines of the grid are printed on
a new page = NOK
The grid must be printed in 1 block. So, in example 2, I need a page with
the datarows and a new page with the grid.

I tried to insert a pagebreak BEFORE the grid, but in that case, in example
1 (where everything fits on one page), I also get 2 pages...

Any solutions to keep that grid printed in 1 block? I can work with VBA...

Thanks in advance!

Sam
 
J

Jim Rech

There is no feature in Excel that automatically keeps a group of rows on the
same printed page. I think you're going to write a macro that intelligently
places manual page breaks so as to get the result you want. You have a set
of macro tools that can tell you where the breaks currently are. Maybe you
can make use of them somehow to set new breaks.

Sub aa()
Dim Brk As HPageBreak
MsgBox Application.ExecuteExcel4Macro("get.document(50)") _
& " total pages will print"
For Each Brk In ActiveSheet.HPageBreaks
MsgBox Brk.Location.Address & " - " & _
IIf(Brk.Type = xlPageBreakAutomatic, "Automatic", _
"Manual")
Next
End Sub


--
Jim
| Hi,
|
| I have an Excel-file with much worksheets (+/- 200). Every worksheet
| contains some or much datarows (sometimes 2 rows, sometimes 5 pages of
| rows).
| At the bottom of every worksheet (not every page), I want to print a grid
of
| about 7 to 10 rows with some data in.
| The porblem I have now is...
| 1. When I print a worksheet of 2 rows data + grid, everything fits on one
| page = OK
| 2. When I print a page of f.e. 20 rows data + grid, the data and the first
3
| lines of my grid are on page 1, the other 5 lines of the grid are printed
on
| a new page = NOK
| The grid must be printed in 1 block. So, in example 2, I need a page with
| the datarows and a new page with the grid.
|
| I tried to insert a pagebreak BEFORE the grid, but in that case, in
example
| 1 (where everything fits on one page), I also get 2 pages...
|
| Any solutions to keep that grid printed in 1 block? I can work with VBA...
|
| Thanks in advance!
|
| Sam
|
|
 
T

Tom Ogilvy

Using VBA code:

Just display pagebreaks. Then if an automatic pagebreak occurs in your grid
(loop through the cells an check), you would place a manual pagebreak above
it. If one does not, you would not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top