ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically Sizing PrintArea (https://www.excelbanter.com/excel-programming/314135-automatically-sizing-printarea.html)

ob3ron02[_6_]

Automatically Sizing PrintArea
 

I was wondering if anyone could suggest a method to dynamically set
PrintArea on a worksheet according to the last used row (the # o
colums will always be constant).

I know to use -Sheet1-.PageSetup.PrintArea = "-A1:F15-" but i can'
figure out how to find the last row with data in it and get th
appropriate range from that last row.

Thanks,

To

--
ob3ron0
-----------------------------------------------------------------------
ob3ron02's Profile: http://www.excelforum.com/member.php...fo&userid=1545
View this thread: http://www.excelforum.com/showthread.php?threadid=27079


Tom Ogilvy

Automatically Sizing PrintArea
 
If you don't set any printarea, it should do what you want.

but,
Last non-empty cell in column A

Dim rng as Range
set rng = Cells(rows.count,1).end(xlup)
' assume 10 columns wide
set rng = Range(Range("A1"), rng).Resize(,10)

Activesheet.PageSetup.PrintArea = rng.Address(external:=True)

--
Regards,
Tom Ogilvy


"ob3ron02" wrote in message
...

I was wondering if anyone could suggest a method to dynamically set a
PrintArea on a worksheet according to the last used row (the # of
colums will always be constant).

I know to use -Sheet1-.PageSetup.PrintArea = "-A1:F15-" but i can't
figure out how to find the last row with data in it and get the
appropriate range from that last row.

Thanks,

Tom


--
ob3ron02
------------------------------------------------------------------------
ob3ron02's Profile:

http://www.excelforum.com/member.php...o&userid=15450
View this thread: http://www.excelforum.com/showthread...hreadid=270797





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

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