Archive of Mr Excel Message Board


Back to Printing in Excel archive index
Back to archive home

PRINT AREA SETUP

Posted by DEE on January 08, 2002 8:37 AM
How can I set up my print area with a range in code. My code looks like this.

Sub PrintGroup1()
Dim Range1 As Range
Dim sheetname As Worksheet
Set sheetname = Worksheets("GROUP")
Set Range1 = sheetname.Range("GROUP")
sheetname.Select
Range("GROUP").Select

With sheetname.PageSetup
.PrintTitleRows = "$1:$10"
.PrintTitleColumns = "$A:$C"
.PrintArea = Range1

End With
sheetname.PrintOut Copies:=1, Preview:=True, Collate:= _
True

End Sub

I keep getting a error message when I try and run the code.


Re: PRINT AREA SETUP

Posted by Scott on January 08, 2002 9:29 AM
If you are using a named range from a spreadsheet, you can use:

ActiveSheet.PageSetup.PrintArea = "Range"

If not, then it looks like you are trying to name the worksheet to Group. You can use:

Sheets("Sheet1").Name = "Group"

Your code looks like you are trying to create a print range for the entire sheet. Is this correct? This would be a lot to print.

With sheetname.PageSetup .PrintTitleRows = "$1:$10" .PrintTitleColumns = "$A:$C" .PrintArea = Range1 End With


This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.