ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with code?? (https://www.excelbanter.com/excel-programming/404172-help-code.html)

Mekinnik

Help with code??
 
How could I modify this code to insert a page break instead of a row and do
it at the top of every 19th row instead of row 5?


Sheets("Sheet1").Select
Range("A1").Select 'Set range to start point
Do While ActiveCell.Value < ""
ActiveCell.Offset(5, 0).Select
Selection.EntireRow.Insert
ActiveCell.Offset(1, 0).Select

Don Guillett

Help with code??
 
Try this
Sub putbreaks()
ActiveSheet.ResetAllPageBreaks
For i = 20 To Cells(Rows.Count, "a").End(xlUp).Row Step 19
ActiveSheet.HPageBreaks.Add Befo=Cells(i, "a")
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Mekinnik" wrote in message
...
How could I modify this code to insert a page break instead of a row and
do
it at the top of every 19th row instead of row 5?


Sheets("Sheet1").Select
Range("A1").Select 'Set range to start point
Do While ActiveCell.Value < ""
ActiveCell.Offset(5, 0).Select
Selection.EntireRow.Insert
ActiveCell.Offset(1, 0).Select




All times are GMT +1. The time now is 06:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com