Insert row after a page break

  • Thread starter Thread starter Benlejedi
  • Start date Start date
B

Benlejedi

Hi,

I have created a subtotal with page breaks.
I insert a row after the subtotal to insert some headers.
The problem is that the new row always before the page break appears.

Can anyone help me for this ?

Thanks a lot in advance

Benjamin
 
OK. Lets say you've inserted your subtotals and then manually inserted a
row below each of these subtotals.

You now have a series of blank rows where you want to insert your new
header.

So... Highlight the active cells in column A (assuming column A is the
column you performed your subtotals on) then try this. It should insert
a page break above each blank row.

Sub PB()
'
'Inserts page break BEFORE each blank row
'
For Each cell In Selection
If cell = "" Then
ActiveSheet.HPageBreaks.Add cell
End If
Next cell
End Sub

Hope it works!

Lee
 
Back
Top