View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
DoctorV[_4_] DoctorV[_4_] is offline
external usenet poster
 
Posts: 1
Default Module to set Page Breaks based on criteria through code

We have a macro that looks at a worksheet which can be up to 200 rows
long. Each row is the same height. Each section in this worksheet has
a letter value assigned to it A, B, C, etc.

Based upon certain conditions the macro will move certain sections of
the data to a new worksheet named Long_Quote, it will auto number all
the rows that come into this new worksheet 1 - whatever, and column B
will have the section codes for the data that came across.

Example:

ColumnA ColumnB
1 A
2 A
3 C
4 C
5 E

etc.

Since each row in the worksheet Long_Quote where the data has come
across is the same row height we need a module that will do the
following:

If we specify 40 as the maximum number of rows to print on one page the
module needs to set a page break at the last change of columnB values
BEFORE THE VALUE OF COLUMNA REACHES 40.

Scenario:
37 A
38 B
39 B
40 B
41 B

In this situation, we would need to set a page break to be set right
below the cell in columnA containing 37, because we do not want to
break up any section of data in the middle of a page break,then go up
to another 40 rows and repeat this process until there are no longer
any numbers in columnA.


---
Message posted from http://www.ExcelForum.com/