Reputation: 21
First time asking a question here. I'm very new to VBA and therefore struggling.
I have 3 columns where I list up dates when I have completed a task. I need to find a way to save all information from last month to a PDF with a push of a button.
But, I can't find a way to only select cells from last month using VBA, and ignoring the cells from current month.
[Date][Names][Results]
Upvotes: 2
Views: 62
Reputation: 54807
Option Explicit
Sub ExportLastMonthToPDF()
With ActiveSheet
If .FilterMode Then .ShowAllData
With .Range("A1").CurrentRegion
.AutoFilter Field:=1, Criteria1:=8, Operator:=xlFilterDynamic
End With
.ExportAsFixedFormat xlTypePDF, "C:\Test\Test.pdf"
.AutoFilterMode = False
End With
End Sub
Upvotes: 1