ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically Changing the Print Area for Pivot Tables (https://www.excelbanter.com/excel-programming/367152-automatically-changing-print-area-pivot-tables.html)

Amy

Automatically Changing the Print Area for Pivot Tables
 
I would like Excel to automatically adjust the print area for a pivot table.
As I select different options, the # of rows change and I have to manually
select the print area to receive the correct printout.

I found one other post about this and I tried to follow the instructions but
I couldn't get it to work. I think I had to write a macro but I'm not sure.
This was what the other thread suggested:

dim i as long
dim j as long
dim rng as range
set rng=range("b1..e1") ' the address of first row of data you want to
print out
j=0
for i = 1 to rng.columns.coun
j=worksheetfunction.max(j,rng.cells(application.Ro ws.Count-rng.Row,1).end(xlup).row)
next i
activesheet.pagesetup.printarea =
rng.Resize(j-rng.row+1,rng.Columns.Count).Address

I consider myself to be an advanced user in Excel but I'm not good with
writing code. I can record a new macro, no problem -- but I'm a novice at
writing one.

If you have a solution to this problem, please write the instructions for a
"dummy". I won't take it personally :)

I am using Excel 2003.

--
Thanks!


All times are GMT +1. The time now is 10:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com