With the code below, the only way can get the pagebreaks to work is to include the Rows("16:16"
.Select line. However, I need to have the pagebreak be variable. If I comment out the Rows line and depend on the Cells(z, 1).Select line, I get an error "Runtime error '1004', Application-defined or Object-defined error" on the PageBreak line.
Can some help steer me in the right direction?
Thanks,
Bob
With Selection.CurrentRegion
rc = .Rows.Count
End With
rc = rc + 50
For z = 1 To rc
If Cells(z, 4).Value = "Initial Balance" Then
Cells(z, 1).Select
Rows("16:16"
.Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Selection.EntireRow.Insert Shift:=xlDown
Selection.EntireRow.Insert Shift:=xlDown
z = z + 2
End If
Next
Can some help steer me in the right direction?
Thanks,
Bob
With Selection.CurrentRegion
rc = .Rows.Count
End With
rc = rc + 50
For z = 1 To rc
If Cells(z, 4).Value = "Initial Balance" Then
Cells(z, 1).Select
Rows("16:16"
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Selection.EntireRow.Insert Shift:=xlDown
Selection.EntireRow.Insert Shift:=xlDown
z = z + 2
End If
Next