Hi all,
Together with Marcol's code and another one that I found
, here is my solution:
Option Explicit
Sub CutAndPasteLast14Rows()
Dim LastRow As Long
LastRow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Worksheets.Add
ActiveSheet.Name = "Summary"
Range("A" & LastRow - 13 & ":A" & LastRow).EntireRow.Cut Sheets("Summary").Range("A1")
' assumes your headers are in row 1 and sheet2 exists and is empty
ActiveSheet.UsedRange.Select
With Selection.Font
.Name = "Lucide Console"
.Size = 7
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
ActiveSheet.Columns("A:A").ColumnWidth = 22.71
Rows("1:14").RowHeight = 12
End Sub
Function Check_PageBreak()
Const sHdr As String = "DOC/DWG #"
Dim iView As XlWindowView
Dim iHdrRow As Long
Dim oHPB As HPageBreak
Dim bFlag As Boolean
Dim iRow As Long
iView = ActiveWindow.View
ActiveWindow.View = xlPageBreakPreview
With Sheet1
.ResetAllPageBreaks
iHdrRow = Columns(4).Find(What:=sHdr, _
LookIn:=xlValues, LookAt:=xlWhole, _
MatchCase:=False).Row
Do
bFlag = False
For Each oHPB In Sheet1.HPageBreaks
With oHPB
If .Type = xlPageBreakAutomatic And _
.Location.Row > iHdrRow Then
bFlag = True
iRow = .Location.Row
Rows(iHdrRow).Copy
.Location.EntireRow.Insert
Sheet1.HPageBreaks.Add Before:=Rows(iRow)
Exit For
End If
End With
Next oHPB
Loop While bFlag
End With
ActiveWindow.View = iView
End Function
It works perfectly!
Thank you, Marcol.
Regards,
Gos-C
Bookmarks