I am trying to set the print area for a spreadsheet and for some reason it will not take my PrintArea setting. I don't want to set anything using .PageSetup except for Print Area. This is because I don't want my code too long or bulky. I'm using the following:
Sub Print_Area_Test()
Sheets("AP Due".Select
'Find Grand Total row
For i = 5 To 65536 Step 1
test4 = Cells(i, 1)
If test4 = "Grand Total" Then
Grand_Tot_row = i
Exit For
End If
Next i
'Find last subtotal column
For i = 1 To 255 Step 1
test2 = Cells(5, i)
If test2 = "Total" Then
Last_col = i
Exit For
End If
Next i
Sheets("AP Due".Activate
ActiveSheet.PageSetup.PrintArea = Range(Cells(6, 1), Cells(Grand_Tot_row, Last_col))
End Sub
The Basis of this array is to find the range. All of the other PageSetup options are set on the worksheet using File/Page Setup. The reason I need to find the Print Area is because the report can change in size.
Everything works, except for the ActiveSheet.PageSetup.PrintArea. The Cells in the Range return the correct range, so I'm a bit confused.
Thanks in advance,
Carie
Sub Print_Area_Test()
Sheets("AP Due".Select
'Find Grand Total row
For i = 5 To 65536 Step 1
test4 = Cells(i, 1)
If test4 = "Grand Total" Then
Grand_Tot_row = i
Exit For
End If
Next i
'Find last subtotal column
For i = 1 To 255 Step 1
test2 = Cells(5, i)
If test2 = "Total" Then
Last_col = i
Exit For
End If
Next i
Sheets("AP Due".Activate
ActiveSheet.PageSetup.PrintArea = Range(Cells(6, 1), Cells(Grand_Tot_row, Last_col))
End Sub
The Basis of this array is to find the range. All of the other PageSetup options are set on the worksheet using File/Page Setup. The reason I need to find the Print Area is because the report can change in size.
Everything works, except for the ActiveSheet.PageSetup.PrintArea. The Cells in the Range return the correct range, so I'm a bit confused.
Thanks in advance,
Carie