ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Print Area Macro Question (https://www.excelbanter.com/excel-discussion-misc-queries/168922-print-area-macro-question.html)

Vick

Print Area Macro Question
 
I'm using a macro worksheet change macro, so that when ever someone changes a
pivottable the sheet will automatically change the print area of the pivot
table. I'm trying the following code, but everytime I try and record I get a
fixed value as you see here. How can I get the print area to use the range I
selected above?

Range("E10").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = "$E$10:$P$32"

Thanks

Bernard Liengme

Print Area Macro Question
 
Change last statement to:
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"Vick" wrote in message
...
I'm using a macro worksheet change macro, so that when ever someone
changes a
pivottable the sheet will automatically change the print area of the pivot
table. I'm trying the following code, but everytime I try and record I get
a
fixed value as you see here. How can I get the print area to use the range
I
selected above?

Range("E10").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = "$E$10:$P$32"

Thanks




Bernard Liengme

Print Area Macro Question
 
But this seems to be OK
ActiveSheet.PageSetup.PrintArea = ActiveWindow.RangeSelection.Address
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"Vick" wrote in message
...
I'm using a macro worksheet change macro, so that when ever someone
changes a
pivottable the sheet will automatically change the print area of the pivot
table. I'm trying the following code, but everytime I try and record I get
a
fixed value as you see here. How can I get the print area to use the range
I
selected above?

Range("E10").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = "$E$10:$P$32"

Thanks





All times are GMT +1. The time now is 07:12 AM.

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