PDA

View Full Version : Solved: Setting the print area for used rows and columns



enfantter
11-22-2007, 12:57 AM
Hey once again all,

Just encountered yet another problem.
Im runing a macro where i want to set the printing area as all the used columns "A:L" and the rows "9:[lastrow]".

My code is like this:
Dim y As Long, lastCell2 As range
y = ActiveSheet.UsedRange.Rows.Count
Set lastCell2 = Cells.SpecialCells(xlCellTypeLastCell)
ActiveSheet.PageSetup.PrintArea = range(Cells(9, 1), lastCell2).Address


but Im guessing that im missing the point here ...
Anyone can help?!

xld
11-22-2007, 01:03 AM
Works fine for me. What is happening?

enfantter
11-22-2007, 01:10 AM
sorry
for me its marking all rows instead of stopping at the last one ...
maybe its my sheet...

xld
11-22-2007, 01:22 AM
Yeah, try this out

http://www.contextures.com/xlfaqApp.html#Unused

enfantter
11-22-2007, 01:41 AM
exactly - thnx!!