Hi Agustus,
Record a macro
Select area, File, Print area
VBA code generated
ActiveSheet.PageSetup.PrintArea = "$A:$F"
you can use
ActiveSheet.PageSetup.PrintArea = Selection.address
or with another range
ActiveSheet.PageSetup.PrintArea = rng.address
The need to set a Print Area is off due to last cell problems
you can check last cell with Ctrl+End for the intersection
of the last used row and the last use column as Excel knows it.
More information in
http://www.mvps.org/dmcritchie/excel/lastcell.htm
For a macro to fix all worksheets in a workbook see
Why do my scrollbars go to row 500 -- my data ends in cell E50?, contextures.com, Debra Dalgleish
http://www.contextures.com/xlfaqApp.html#Unused use the macro under that topic
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm
> Hi,
>
> I have selected a range on on the activeworksheet. How do I set the
> range into the print area using VBA?
>
> TIA
Agustus - 26 Apr 2006 18:46 GMT
Thanks, David. Your tips are very helpful.