Page Brakes

A

Aaron

I have a bunch of data as follows:

a b c d e
abc 321 $14
abc 315 $10
Result $24
cba 798 $15
cba 896 $6
Result $21

I want to page brake at the row below each result. Any Ideas? the result
row is embeded in the data so it I try subtotaling it adds my existing result
row. This data is an extract and I cannot rid the result line.

please Help
 
F

Frank Kabel

Hi
try the following macros (insert a pagebreak if the value in
column A is equal to 'Result'). Adapt this to your needs

Option Explicit
Sub insert_pagebreak()
Dim lastrow As Long
Dim row_index As Long

lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index, "A").Value ="Result" then
ActiveSheet.HPageBreaks.Add Before:= _
Cells(row_index + 1, "A")
End If
Next
End Sub

Sub remove_them()
ActiveSheet.ResetAllPageBreaks
End Sub
 
A

Aaron

Thanks.. that worked great!!

Frank Kabel said:
Hi
try the following macros (insert a pagebreak if the value in
column A is equal to 'Result'). Adapt this to your needs

Option Explicit
Sub insert_pagebreak()
Dim lastrow As Long
Dim row_index As Long

lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index, "A").Value ="Result" then
ActiveSheet.HPageBreaks.Add Before:= _
Cells(row_index + 1, "A")
End If
Next
End Sub

Sub remove_them()
ActiveSheet.ResetAllPageBreaks
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top