Print Area

Claire Jackson

Board Regular
Joined
Jun 30, 2020
Messages
74
Office Version
  1. 2016
Platform
  1. Windows
HELP!

I need a simple macro to print an area of a worksheet which always starts at CELL "F5" and all the way to across to column "Z" but the length of the data will change as it's a pivot table, so print area could be F5..Z12 or could be F5..Z37 etc. etc.

It's not just the pivot table I'm printing, I have some formulas to the right too that are in the area that needs printing (columns J-Z)

If anyone can help that'd be great :)
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try this:
VBA Code:
Sub MySetPrintArea()
    
'   Find last row in column Z with data
    Dim lrow As Long
    lrow = Cells(Rows.Count, "Z").End(xlUp).Row
    
'   Set print area
    ActiveSheet.PageSetup.PrintArea = "$A$2:$Z$" & lrow
    
End Sub
 
Upvote 0
Solution
You are welcome.
 
Upvote 0

Forum statistics

Threads
1,215,259
Messages
6,123,922
Members
449,135
Latest member
NickWBA

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