Hi, the below code filters last month and all months prior, but I would like to filter for two months prior ie in March I would like Jan and all months prior, cheers.
Code
- Private Sub Previous_Months()
- 'filter for previous months
- 'startdate as date
- Dim startDate As Date
- 'startdate as long for excel
- Dim lstartDate As Long
- 'get start date, day = always 1
- startDate = DateSerial(Year(Now), Month(Now), 1)
- lstartDate = startDate
- 'filter FOR everything before current month
- 'you see PREVIOUS MONTHS
- Range("I6").AutoFilter Field:=8, Criteria1:="<=" & lstartDate
- End Sub