Code for printing pages

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,476
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

On my worksheet range A1:K4 are used as my sheet 'headers'
rows 4:70 are then used to place data

I want to change the simple code I have that prints all the data.

I want the headers in range A1:K4 to be shown at the top of each page printed.

for example

Page 1 will print the headers on range A1:K4 then all the data on rows 5:19
Page 2 will print the headers on range A1:K4 then all the data on rows 20:35
Page 3 will print the headers on range A1:K4 then all the data on rows 36:51
etc etc

Obviously I only want the above 'pages' to be printed if there is data on them

is this possible??

thanks in advance
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Gunswick

Board Regular
Joined
Jun 18, 2008
Messages
179
this is simple.

open the help function in excel, and search for "print header"

the first item will be the one you need.

Row headings are the row numbers to the left of the worksheet; column headings are the letters or numbers that appear at the top of the columns on a worksheet.
  1. Click the worksheet.
  2. On the File menu, click Page Setup, and then click the Sheet tab.
  3. Do one of the following: Print row and column headings
    • Select the Row and column headings check box, and click Print.
    Print row and column labels on every page
    • To print column labels on every page, under Print titles in the Rows to repeat at top box, enter the rows that contain the column labels, and then click Print.
    • To print row labels on every page, under Print titles in the Columns to repeat at left box, enter the columns that contain the row labels, and then click Print.

then open print preview, and click page break preview at the top, then you can adjust the blue bars to your print areas. to get back to a normal view, just go to print preview again and press normal view.


EDIT:
if you want the VBA code for this, then start recording a macro and then do the above, once finished just stop recording. that way it will create the code for you, and you can just paste it into your current macro, and it will be repeatable whenever you want.
 
Last edited:

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,476
Office Version
  1. 2016
Platform
  1. Windows
..not too sure if I follow that - but I'll have a go

One other point, how do I make sure that only the populated 'pages' are printed??
 

Watch MrExcel Video

Forum statistics

Threads
1,122,658
Messages
5,597,403
Members
414,142
Latest member
Banyangt

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
Top