View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Format Page breaks

Give this macro a try (change the worksheet name reference to the worksheet
name you want to apply this code to)...

Sub AddPageBreaks()
Dim X As Long
Dim LastRow As Long
With Worksheets("Sheet1")
.Cells.PageBreak = xlPageBreakNone
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
For X = 2 To LastRow
If .Cells(X - 1, "B").Value < .Cells(X, "B").Value Then
.Rows(X).PageBreak = xlPageBreakManual
End If
Next
.Rows(LastRow + 1).PageBreak = xlPageBreakManual
End With
End Sub

--
Rick (MVP - Excel)


"Matt G" wrote in message
...
Hi,

I'm trying to write a macro that will sort sheet by a particular column
"B"
and then llok through that column and set a page break whenever the value
of
any row in comumn "B" changes.

For example:
A B C
1 r t g
---------------------- Page Break
2 d u w
3 s u e
---------------------- Page Break
4 e v d

Any Ideas?

Thanks in advance