View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
E.Sortland[_2_] E.Sortland[_2_] is offline
external usenet poster
 
Posts: 2
Default Need help creating a variable size printarea marco.

Exactly what I was looking for! Thank you very much.

Best regards,
Espen

"Tom Ogilvy" wrote:

Assuming the code you posted selects the proper printarea, then

Range("B8").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
Range("G5").Select

--
Regards,
Tom Ogilvy


"E.Sortland" wrote:

Hi, hopefully someone can point me in the right direction.

I'm having trouble making a macro for a variable size print area.

My code so far:
Range("B8").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveSheet.PageSetup.PrintArea = "$B$8:$H$273"
Range("G5").Select

In the example above when i create the macro i have text in the area from B8
to H273, but if my text changes, the macro still selects this range to
printarea, making the area either to big or to small.

I have tried using this command from another workbook, but the results are
not what I'm looking for:
ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address