Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How do I insert a page break before each change in the cell conten

I need to write a Macro or VB Script that will insert page breaks above each
row that contains new contents in a particular cell. One column contains the
work location for our employees in code form (i.e. N002), and page breaks
need to be inserted to separate each work location, so there would need to be
a page break at the point that the Work location code changes from N002 to
N003. This is an extremely time-consuming task that has to be performed on
multiple reports every two weeks. Your help is appreciated!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default How do I insert a page break before each change in the cell conten

Assuming your data has no blank cells in the column you are looking at, this
will get you started:

Do While ActiveCell.Value < xlnull
If ActiveCell.Value < ActiveCell.Offset(1, 0) Then
ActiveWindow.SelectedSheets.HPageBreaks.Add
Befo=ActiveCell.Offset(1, 0)
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub

This is just a quick piece of code, but will get you well on your way if you
can do any VB prog at all. Good luck!

"ronda" wrote:

I need to write a Macro or VB Script that will insert page breaks above each
row that contains new contents in a particular cell. One column contains the
work location for our employees in code form (i.e. N002), and page breaks
need to be inserted to separate each work location, so there would need to be
a page break at the point that the Work location code changes from N002 to
N003. This is an extremely time-consuming task that has to be performed on
multiple reports every two weeks. Your help is appreciated!!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default How do I insert a page break before each change in the cell conten

Several questions need to be answered first:
1. Is this a list of existing employees, who periodically change work
locations (hence you are simply editing the location)?

Or
2 Are you adding new employees at the bottom of the list?

3. Is the list sorted (or does it first need to be sorted) on the location
column
so that all workers working a specific location will be first grouped on a
printed page? If not sorted, it seems you would end up with possibly a
separate printed page for each employee? If this is not desired then a sort
would be required after the data entry/edit but before the page break insert.

"ronda" wrote:

I need to write a Macro or VB Script that will insert page breaks above each
row that contains new contents in a particular cell. One column contains the
work location for our employees in code form (i.e. N002), and page breaks
need to be inserted to separate each work location, so there would need to be
a page break at the point that the Work location code changes from N002 to
N003. This is an extremely time-consuming task that has to be performed on
multiple reports every two weeks. Your help is appreciated!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default How do I insert a page break before each change in the cell conten

ronda

To insert the pagebreaks.

Sub InsertBreak_At_Change()
Dim i As Long
For i = Selection.Rows.Count To 1 Step -1
If Selection(i).Row = 1 Then Exit Sub
If Selection(i) < Selection(i - 1) And Not IsEmpty _
(Selection(i - 1)) Then
With Selection(i)
.PageBreak = xlPageBreakManual
End With
End If
Next
End Sub

Note gocush's comments and questions also.

Gord Dibben Excel MVP

On Mon, 6 Dec 2004 21:45:01 -0800, gocush
wrote:

Several questions need to be answered first:
1. Is this a list of existing employees, who periodically change work
locations (hence you are simply editing the location)?

Or
2 Are you adding new employees at the bottom of the list?

3. Is the list sorted (or does it first need to be sorted) on the location
column
so that all workers working a specific location will be first grouped on a
printed page? If not sorted, it seems you would end up with possibly a
separate printed page for each employee? If this is not desired then a sort
would be required after the data entry/edit but before the page break insert.

"ronda" wrote:

I need to write a Macro or VB Script that will insert page breaks above each
row that contains new contents in a particular cell. One column contains the
work location for our employees in code form (i.e. N002), and page breaks
need to be inserted to separate each work location, so there would need to be
a page break at the point that the Work location code changes from N002 to
N003. This is an extremely time-consuming task that has to be performed on
multiple reports every two weeks. Your help is appreciated!!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How do I insert a page break before each change in the cell co

OK,
1. It is a list of existing employees who periodically change work
locations, however (this answers #2, also) I am downloading the list out of a
network data program, so I am not recreating the list each time.

3. Yes, it is sorted.

One last thing, I am super-newbie at VB script. Any suggestions for
learning the language would be awesome.

Thanks!

"gocush" wrote:

Several questions need to be answered first:
1. Is this a list of existing employees, who periodically change work
locations (hence you are simply editing the location)?

Or
2 Are you adding new employees at the bottom of the list?

3. Is the list sorted (or does it first need to be sorted) on the location
column
so that all workers working a specific location will be first grouped on a
printed page? If not sorted, it seems you would end up with possibly a
separate printed page for each employee? If this is not desired then a sort
would be required after the data entry/edit but before the page break insert.

"ronda" wrote:

I need to write a Macro or VB Script that will insert page breaks above each
row that contains new contents in a particular cell. One column contains the
work location for our employees in code form (i.e. N002), and page breaks
need to be inserted to separate each work location, so there would need to be
a page break at the point that the Work location code changes from N002 to
N003. This is an extremely time-consuming task that has to be performed on
multiple reports every two weeks. Your help is appreciated!!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How do I insert a page break before each change in the cell co

Yah, let me reply again, because I'm stupid! In the place of the "i" should
I be giving the column letter, or a range of cells? I'm assuming!

"Gord Dibben" wrote:

ronda

To insert the pagebreaks.

Sub InsertBreak_At_Change()
Dim i As Long
For i = Selection.Rows.Count To 1 Step -1
If Selection(i).Row = 1 Then Exit Sub
If Selection(i) < Selection(i - 1) And Not IsEmpty _
(Selection(i - 1)) Then
With Selection(i)
.PageBreak = xlPageBreakManual
End With
End If
Next
End Sub

Note gocush's comments and questions also.

Gord Dibben Excel MVP

On Mon, 6 Dec 2004 21:45:01 -0800, gocush
wrote:

Several questions need to be answered first:
1. Is this a list of existing employees, who periodically change work
locations (hence you are simply editing the location)?

Or
2 Are you adding new employees at the bottom of the list?

3. Is the list sorted (or does it first need to be sorted) on the location
column
so that all workers working a specific location will be first grouped on a
printed page? If not sorted, it seems you would end up with possibly a
separate printed page for each employee? If this is not desired then a sort
would be required after the data entry/edit but before the page break insert.

"ronda" wrote:

I need to write a Macro or VB Script that will insert page breaks above each
row that contains new contents in a particular cell. One column contains the
work location for our employees in code form (i.e. N002), and page breaks
need to be inserted to separate each work location, so there would need to be
a page break at the point that the Work location code changes from N002 to
N003. This is an extremely time-consuming task that has to be performed on
multiple reports every two weeks. Your help is appreciated!!



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default How do I insert a page break before each change in the cell co

ronda

Assuming the work location column has no blanks, just select top cell of that
column then SHIFT + END + DownArrow then run the macro through
ToolsMacroMacros.

Gord

On Tue, 7 Dec 2004 10:49:04 -0800, "ronda"
wrote:

Yah, let me reply again, because I'm stupid! In the place of the "i" should
I be giving the column letter, or a range of cells? I'm assuming!

"Gord Dibben" wrote:

ronda

To insert the pagebreaks.

Sub InsertBreak_At_Change()
Dim i As Long
For i = Selection.Rows.Count To 1 Step -1
If Selection(i).Row = 1 Then Exit Sub
If Selection(i) < Selection(i - 1) And Not IsEmpty _
(Selection(i - 1)) Then
With Selection(i)
.PageBreak = xlPageBreakManual
End With
End If
Next
End Sub

Note gocush's comments and questions also.

Gord Dibben Excel MVP

On Mon, 6 Dec 2004 21:45:01 -0800, gocush
wrote:

Several questions need to be answered first:
1. Is this a list of existing employees, who periodically change work
locations (hence you are simply editing the location)?

Or
2 Are you adding new employees at the bottom of the list?

3. Is the list sorted (or does it first need to be sorted) on the location
column
so that all workers working a specific location will be first grouped on a
printed page? If not sorted, it seems you would end up with possibly a
separate printed page for each employee? If this is not desired then a sort
would be required after the data entry/edit but before the page break insert.

"ronda" wrote:

I need to write a Macro or VB Script that will insert page breaks above each
row that contains new contents in a particular cell. One column contains the
work location for our employees in code form (i.e. N002), and page breaks
need to be inserted to separate each work location, so there would need to be
a page break at the point that the Work location code changes from N002 to
N003. This is an extremely time-consuming task that has to be performed on
multiple reports every two weeks. Your help is appreciated!!




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default How do I insert a page break before each change in the cell conten

Another option would be to use Data|Subtotals.

There's an option to insert a "page break between groups".

And you'd get the subtotals, too!

ronda wrote:

I need to write a Macro or VB Script that will insert page breaks above each
row that contains new contents in a particular cell. One column contains the
work location for our employees in code form (i.e. N002), and page breaks
need to be inserted to separate each work location, so there would need to be
a page break at the point that the Work location code changes from N002 to
N003. This is an extremely time-consuming task that has to be performed on
multiple reports every two weeks. Your help is appreciated!!


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Page Break Adjustments causes a page break each cell BKaufman Excel Worksheet Functions 2 September 10th 10 05:02 AM
Insert Page Break da Excel Discussion (Misc queries) 2 May 11th 09 07:05 PM
Help! How do I insert a manual page break on a change in cell contents Al Dykes Excel Discussion (Misc queries) 2 July 23rd 08 09:25 PM
change and/or remove page number watermark in page break preview juga Excel Discussion (Misc queries) 2 December 25th 06 10:15 AM
insert page break when there is a change in the row value [email protected] Excel Worksheet Functions 3 July 14th 06 07:20 PM


All times are GMT +1. The time now is 04:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"