Print Area Macro

N

NICK

Hi All

I would like to write a macro which selects a range which I have named as
the print area.

I am able to select a print area by writing (for example):

ActiveSheet.PageSetup.PrintArea = "$A$1:$A$10"

However, if I name the range A1:A10 as "PrintArea" then I would think the
following macro should work but it does not:

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

If anyone has any ideas it would be greatly appreciated!

Cheers
Nick
 
L

Leo Heuser

Hi Nick

A string with the address of the cells to be printed
is expected, so instead use:

ActiveSheet.PageSetup.PrintArea = Range("PrintArea").Address
 
F

Frank Stone

hi,
one way to do this is to have the macro declare the area
to print a range name. then have the print area = the
range name. for example:
ActiveWorkbook.Names.Add Name:="RangeName", RefersTo:= _
Range("A1", Range("A1").end(xldown) _
.offset(0,10))
ActiveSheet.PageSetup.PrintArea = "RangeName"
'ActiveWindow.SelectedSheets.PrintPreview
'ActiveWindow.SelectedSheets.PrintOut Copies:=4, _
Collate:=True

this sniplet would select a range 10 columns wide and
however many rows you have. then choose wheather you want
to preview the report or just print it and how many copies.

reguards
Frank
 
Top