Search and replace by page break

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Has anybody got a clue how I can record a search and replace macro which inserts a page break at certain results
Recording it doesn't seem to work. Maybe a visual basic example

Thanks in advance

Emiel, Holland
 
Hello Emiel,

Try something like this:
Range("A" & iHdrRowNdx & ":Z" & iLastRowNdx).Select
With ActiveSheet.UsedRange
For RowNdx = iHdrRowNdx + 1 To iLastRowNdx
If Range("A" & RowNdx) <> Range("A" & RowNdx + 1) Then
Range("A" & RowNdx + 1).Select
ActiveWindow.SelectedSheets.HPageBreaks.Add
Before:=ActiveCell
End If
Next RowNdx
End With

Where iHdrRowNdx is your starting point and iLastRowNdx is the ending
point. In this example, I compare the current index val w/ the next
index value if they are different, then I insert a page break. You
could easily change the if statement to your "certain results." I
hope this helps some.
 
Back
Top