Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting a large print area

Status
Not open for further replies.

cwinnyk

Programmer
May 27, 2003
62
US
Hello everyone. I'm trying to set a print area within my spread sheet. When I record the macro, this is the code I get...

Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveCell.Range("A1:AA256").Select
ActiveSheet.PageSetup.PrintArea = "$C$10:$AC$265"

I need the program to actually to perform "Shift-EndDown" keysequence three times. When I run the macro though, the selection never moves past the first key sequence. I think I know why, but I don't know any VBA way to step around this.

Also, my row count will always be different each time I run the macro, but, once again, I'm not sure how to digest that solution into VBA.

Any help would be greatly appreciated. :)

Chris
 
Hi Chris,

Instead of going from the top and go down, start from the bottm and go up. . .

Try this:
ActiveSheet.PageSetup.PrintArea = "$C$10:$AC$" & Range("A65536").End(XLUp).Row

Thanks!
-Gorth
 
If the intent is to simply go to the last row and last column you can do this:

Set LastCell = Worksheets("SheetName").Cells.SpecialCells(xlLastCell)
Row = LastCell.Row
Column = LastCell.Column
Worksheets("SheetName").PageSetup.PrintArea = "$B$" & Column & ":$AB$" & Row
 
Hey guys:

Thanks for your advice. I just decided to name my range and use that instead. So, I changed it to this:

ActiveSheet.PageSetup.PrintArea = Range("PRINTRANGE")

I should have did that in the firstplace, but, it's Monday. I'm braindead. :)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top