Option Explicit
Sub mep()
Dim dl As Long, col As Byte, HPage As Integer, VPage As Byte, x As Integer
ActiveWindow.View = xlPageBreakPreview
With ActiveSheet
dl = .UsedRange.Rows.Count
.ResetAllPageBreaks
.PageSetup.PrintArea = "A1:k" & dl
.PageSetup.PrintTitleRows = "$1:$4"
HPage = .HPageBreaks.Count
VPage = .VPageBreaks.Count
If VPage >= 1 Then .VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
If HPage >= 1 Then
For x = dl To 1 Step -1
If .Cells(x, 9).Borders(xlEdgeTop).LineStyle = xlContinuous Then
.HPageBreaks.Add Before:=Range("A" & x - 1)
Exit For
End If
Next x
End If
End With
ActiveWindow.View = xlNormalView
End Sub