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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Print Area

Status
Not open for further replies.

mep1

IS-IT--Management
Jun 18, 2003
67
0
0
US
Hi,
I am trying to select a print area but am having trouble with the syntax of my variables.

Set startPrintRange = thisStartRange.Offset(-x, 0)
Set endPrintRange = thisStartRange.Offset(0, 11)
Range(startPrintRange, endPrintRange).Select

ActiveSheet.PageSetup.PrintArea = startPrintRange & ":" & endPrintRange
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

Thanks,
mep
 
If you want a print area it's much easier to define the print area as a name on the sheet where it occurs, and refer to it as a range.

Richard
 
But, if you have good reason for doing it the way you are, here's some working syntax:
Code:
TopLeftCellAddress = thisStartRange.Offset(-x, 0).Address
PrintRange = TopLeftCellAddress & ":" & thisStartRange.Offset(0, 11).Address
ActiveSheet.PageSetup.PrintArea = PrintRange
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Note that thisStartRange must be a valid single-cell range, and that TopLeftCellAddress and PrintRange are string variables.

Hope that gets you what you are after!


VBAjedi [swords]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top