Insert Header row & page break after x number of rows

Hugo1998

New Member
Joined
Jan 26, 2022
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Hi All, I have a spreadsheet where I want to Insert the header row and a page break every 60 rows for printing. I have uploaded an image of my spreadsheet here:
The header row is A11 to U11 and I want to insert this and a page break every 60 rows for printing. On the spreadsheet you can see that all the rings are separated by a blank row. I would like the header row to be inserted at the next available blank row after 60 rows so that the page break does not separate a ring. I have searched everywhere for information on how to do this but have had no luck. Any help will be greatly appreciated.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
This macro will divide your pages but be aware that with font Arial size 12 you will never fit 60 rows in a page, size 9 would be okay elsewise you will have to use a smaller font.
VBA Code:
Option Explicit
Sub Divide_Print_Page()
    Dim x      As Long
    Dim lr     As Long
    Dim np     As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    np = Application.WorksheetFunction.RoundDown((lr + 11) / 60, 0)
    For x = 1 To np
        ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Range("A" & 12 + x * 60)
    Next x
    With ActiveSheet.PageSetup
        .PrintArea = "$A$12:$K$" & lr
        .PrintTitleRows = "$A$11:$U$11"
        .FitToPagesWide = 1
        .FitToPagesTall = False
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,011
Messages
6,122,680
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top