I have a template that could be any where from 12 rows to 1500 rows of data, is there a macro that will look for the last populated row (however, could contain a formula but no value) and stop the print area as to not print extra blank pages?
I have a template that could be any where from 12 rows to 1500 rows of data, is there a macro that will look for the last populated row (however, could contain a formula but no value) and stop the print area as to not print extra blank pages?
I have a fairly specific data area, but this might help you. Change the last Row and last Column from A & 1 if you don't have data on A or row 1. Choose the longest column and longest row. I have a specific row and a specific column which I always need to use for the total page length/width.
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks