I have a macro that pulls a report from one worksheet, then pulls applicable data from another worksheet, and prints both pages to a single PDF file. The print to pdf side of it is working, but filtering the data to match the report is not.
I started with defining the start and end dates from the report, then I would like to filter the first column of my data worksheet based on this date range before printing.
My code is below:
Dim StartDate as Date, EndDate as Date, DataTable as String
EndDate = ActiveSheet.Range("G6")
StartDate = ActiveSheet.Range("G5")
Worksheets("Data").Activate
DataTable = Worksheets("Data").Range("A2").CurrentRegion.Address
ActiveSheet.Range(DataTable).AutoFilter Field:=1, Criteria1:=">=" & StartDate, Operator:=xlAnd, Criteria2:="<=" & EndDate
Changing the filter manually before running the macro does work, but I'd like for the macro to do it on its own. Any advice is much appreciated.