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.



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