I have several sheets (some Pivot tables) in a 2007 Workbook and would like to set the print area to the last row (last cell) of each sheet. The sheets are all different sizes. So far I have:
Sub test_Print_Area()
Dim c As Long, Printa As Range
c = ActiveSheet.Cells(2, Columns.Count).End(xlToLeft).Column
Set Printa = ActiveSheet.Range(Cells(1, 1), Cells(Rows.Count, c).End(xlUp))
ActiveSheet.PageSetup.PrintArea = Printa.Address
End Sub
This works for one sheet and I need to for all the sheets in the book. I think I can use " For each" statement but I can't get it to work.
Help would be appreciated. Thanks
Sub test_Print_Area()
Dim c As Long, Printa As Range
c = ActiveSheet.Cells(2, Columns.Count).End(xlToLeft).Column
Set Printa = ActiveSheet.Range(Cells(1, 1), Cells(Rows.Count, c).End(xlUp))
ActiveSheet.PageSetup.PrintArea = Printa.Address
End Sub
This works for one sheet and I need to for all the sheets in the book. I think I can use " For each" statement but I can't get it to work.
Help would be appreciated. Thanks