May 05 2021 04:07 PM
I have a 698 line Excel file that I need separated at every 5th line. How do I create a marco to accomplish this or is there a way to do this by using the insert page break option? I'm using Excel for Office 365
May 06 2021 12:39 AM
Here is a macro:
Sub InsertPageBreaks()
Dim r As Long
Dim m As Long
ActiveSheet.ResetAllPageBreaks
m = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Range("A" & m).Select
For r = 6 To m Step 5
ActiveSheet.HPageBreaks.Add Before:=Range("A" & r)
Next r
End Sub