PDA

View Full Version : Solved: print area



philfer
01-25-2008, 12:47 PM
Hello,

I tried the following code

Dim rng as String

With ActiveSheet
rng = .Range("A1", ActiveCell.SpecialCells(xlLastCell)).Address)
.PrintArea = rng
End With

I get the following error

Object not support this property or method

Can anyone help

Carl A
01-25-2008, 01:28 PM
I think this is what you are trying to do. It involves a loop to find last empty cell. There is probably a better way to select the last row.

With ActiveSheet
.Range("A1").Select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Loop
.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address
End With

Carl A
01-25-2008, 03:09 PM
Better

With ActiveSheet
Range("A:A").SpecialCells(xlCellTypeLastCell).Select
.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address
End With