Dynamic Print Range Macro?


Posted by Travis Harr on September 25, 2001 12:36 PM

I am trying to create a simple macro that sets the print range so that if the number of rows changes, the macro will expand to print all rows the range.
The problem is that when I record the macro it hard codes the print area to look like below.

Sub Macro1()
Range("A1").Select
Selection.End(xlDown).Select
Range("A5:E1").Select
ActiveSheet.PageSetup.PrintArea = "$A$5:$E$1"
End Sub

Is there a way to dynamically change the print range So that instead of starting at "A5" (in this case) it would start where the "xlDown" ends?

Any help is greatly appreceated

Posted by Dank on September 25, 2001 1:11 PM

How about this?

Sub Macro1()
ActiveSheet.PageSetup.PrintArea = Range("A1:E1", Range("A1:E1").End(xlDown)).Address
End Sub

Regards,
Dan.



Posted by Travis Harr on September 25, 2001 1:17 PM


Perfect! Thanks for the help, Travis