Insert row after a page break

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
 
R

roundabout

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
 

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

Similar Threads


Top