I'm trying to set a print range that varies for each sheet based the last row in column M having data. Right now I have each one set to M175, but some of the pages print out blank and I'd rather it just find the last column that has data and not have to delete pages. It's multiple sheets, but I just included two below. Any ideas on how to write this code?
VBA Code:
Sub FHWAPrintPDF()
Dim myfhwa As Worksheet
Set myfhwa = ActiveSheet
With ActiveSheet.PageSetup
.Orientation = xlPortrait
.LeftMargin = Application.InchesToPoints(0.35)
.RightMargin = Application.InchesToPoints(0.35)
.TopMargin = Application.InchesToPoints(0.35)
.BottomMargin = Application.InchesToPoints(0.5)
.FitToPagesTall = False
.FitToPagesWide = 1
.LeftFooter = "&16 " & Range("B6")
.CenterFooter = ""
.RightFooter = "&16 " & Range("F6")
End With
Sheets("27219").Activate
ActiveSheet.Range("A1:M57" & "," & "A59:M175").Select
ActiveSheet.PageSetup.Orientation = xlPortrait
Sheets("27316").Activate
ActiveSheet.Range("A1:M57" & "," & "A59:M175").Select
ActiveSheet.PageSetup.Orientation = xlPortrait
Sheets(Array("27219", "27316")).Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=ThisWorkbook.Path & "/" & "ACDPW.FHWA.Report." & Format(Date, "DDMMMYYYY"), _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
OpenAfterPublish:=True, _
IgnorePrintAreas:=False
ThisWorkbook.Sheets("Dashboard").Activate
End Sub