Put data rows per sheet

  • Thread starter Thread starter girapas
  • Start date Start date
G

girapas

I have an Excel workbook with 2 sheets. One of them is for data entering
(e.g. rows: employee's name, ID#, working dates, fee etc.) and the other
presents that data among other constant value cells (e.g. name of company,
titles of columns, place for signatures etc.). What I want is when data in
the presentation sheet reach at 22 rows to be automatically continued to the
next page of the sheet. So, each printed page will always shows 22 rows of
data with the constant data ABOVE and BELOW of these 22 rows. Thanks,
 
Hi
not fully automatic but try the following two macros (assumption: row 1
is a heading row and you have setup the page that row 1 is repeated on
each page 'File - Pagesetup - Sheet'):

Option Explicit
Sub insert_pagebreak()
Dim lastrow As Long
Dim row_index As Long

lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For row_index = 23 to lastrow - 1 Step 22
ActiveSheet.HPageBreaks.Add Before:= _
Next
End Sub

Sub remove_them()
ActiveSheet.ResetAllPageBreaks
End Sub
 
Typo

Sub insert_pagebreak()
Dim lastrow As Long
Dim row_index As Long

lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For row_index = 23 To lastrow - 1 Step 22
ActiveSheet.HPageBreaks.Add Before:=Cells(row_index, 1)
Next
End Sub
 
Thank you Frank and Ron for your help.




Ron de Bruin said:
Typo

Sub insert_pagebreak()
Dim lastrow As Long
Dim row_index As Long

lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For row_index = 23 To lastrow - 1 Step 22
ActiveSheet.HPageBreaks.Add Before:=Cells(row_index, 1)
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top