How to insert a page break every 10 lines

  • Thread starter Thread starter excellearner
  • Start date Start date
E

excellearner

Hi,

I have been stumped on this one. I have been trying to write a macr
for days on inserting a page break every 10 lines and haven't been abl
to figure it out. I will have have to write a macro to insert a blan
row every two lines.

Thanks,
Ev
 
Eva,

The following code will insert a page break every 10 rows. Change the
values of StartRow and EndRow to meet your needs.


Dim RowNdx As Long
Dim StartRow As Long
Dim EndRow As Long

Dim WS As Worksheet
Set WS = ActiveSheet

StartRow = 11 '<< CHANGE
EndRow = 100 '<< CHANGE

For RowNdx = StartRow To EndRow Step 10
WS.HPageBreaks.Add before:=Rows(RowNdx)
Next RowNdx


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Eva

Chip looked after the page breaks. This code will insert a blank row every
two rows. Or did you mean "alternating rows"? In that case, change the
Step -2 to Step -1

Sub InsertALTrows()
'David McRitchie, misc 2001-06-30
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim i As Integer
For i = Selection(Selection.Count).Row To Selection(1).Row + 1 Step -2
Rows(i).EntireRow.Insert
Next i
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

Gord Dibben XL2002
 
Back
Top