![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 2
|
Hello. Excel '97 here...
What I have is a three-column sheet where the second column is filled with one of around 10 names. I need to know how to insert a page break (automatically) when the name in the second column changes (for example...if the first three rows have Jones as the name in the second column and then the next row has Smith, I need for it to insert a page break because the name changed). I understand how to insert a page break by hand but I'm trying to automate this process. Thanks in advance for any assistance anyone might can offer! BEEK "Everyone will have eternal life...where will you spend yours?" [ This Message was edited by: BEEK on 2002-03-14 11:47 ] [ This Message was edited by: BEEK on 2002-03-14 11:49 ] |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Try using the following code where a1 is the location of the first name:
Range("a1").Select For i = 1 To 10 If Not ActiveCell.Value = ActiveCell.Offset(1, 0).Value Then ActiveWindow.SelectedSheets.HPageBreaks.Add before:=ActiveCell.Offset(1, 0) End If ActiveCell.Offset(1, 0).Select Next i End Sub I hope this helps. Kind regards, Al. |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Posts: 2
|
Thanks Al Chara...that code works beautifully...
BEEK |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|