View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Page Break when a column changes

Hi,

Am Mon, 18 Nov 2013 17:59:19 +0000 schrieb jaimeA:

Is it possible to create a macro that will insert pagebreaks after any
change in column A, after row A6 (so it will exclude the title and info
that comes before that), but that it also excludes changes that include
the fixed text "total 1" and "total 2"?

So it will look:

Author
Peter
Total 1
Total 2

(page break)

Jason
total 1
Total 2


try:
Sub PageBreak()
Dim LRow As Long
Dim rngC As Range

With ActiveSheet
LRow = .Cells(Rows.Count, 1).End(xlUp).Row
.ResetAllPageBreaks
For Each rngC In Range("A6:A" & LRow)
If rngC = "Total 2" Then
.HPageBreaks.Add rngC.Offset(1, 0)
End If
Next
End With
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2