I've been beating up google for the last few days trying to compile this macro for my workbook without any luck. Some codes that work, only do the current worksheet and others don't get off the ground. I need to set the print area to be the last filled row in each worksheet for when I use another macro to save each worksheet as a pdf, it doesn't print extra sheets or split the columns. This is one macro that I have found that partly gets what I want, but it is limited to the current page:
Sub PageSetup
Dim LastRow As Long
Dim LastCol As Long
Dim myRng As Range
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
Set myRng = .Range("A1", .Cells(LastRow, LastCol))
.PageSetup.PrintArea = myRng.Address(external:=True)
End With
End Sub
I'd like it to work across every worksheet in the book. I'm a rookie with scripting and everything I tried to change has failed. Any help will be greatly appreciated!
Sub PageSetup
Dim LastRow As Long
Dim LastCol As Long
Dim myRng As Range
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
Set myRng = .Range("A1", .Cells(LastRow, LastCol))
.PageSetup.PrintArea = myRng.Address(external:=True)
End With
End Sub
I'd like it to work across every worksheet in the book. I'm a rookie with scripting and everything I tried to change has failed. Any help will be greatly appreciated!