Could any help be offered to try and change the below macro to something more automated. The below macro will filter data in fonction of start and end dates entered manually. I wish to do away with having to enter the dates manually and put a code that allows to filter data 12 months ago. I can't use the inbuilt one year filter in excel because; supposing we're in the middle of the year and i filter for 12 months, it will indeed filter data for the whole of 2018 yet my request will have been to filter 12 months from last month before the actual month we may be in. If i've not been clear enough, i will be happy to be precise for anyone with any idea. Thank you in advance for any help
This is for excel 2010 vba. I tried to do some reseach but to no avail and any solution makes the code give an error. But am still searching for solutions
Sub filter_()
Sheets("data1 ").Select
MsgBox "12 months filter"
lngStart = Application.InputBox("Enter start date of interest as dd/mm/yyyy", Type:=1 + 2)
lngEnd = Application.InputBox("Enter end date of interest as dd/mm/yyyy", Type:=1 + 2)
Sheets("RBT-RAT ").Select
Range("Tableau1[[#Headers],[Date dernier freinage]]").Select
ActiveSheet.ListObjects("Tableau1").Range.AutoFilter Field:=30, _
Criteria1:=">=" & lngStart, _
Operator:=xlAnd, _
Criteria2:="<=" & lngEnd
End sub
I expect the code to be able to run without manually having to type in the start and end dates within which the filter should be applied and still filter in function of 12 months from which ever time of the year but without applying the filter from the current month. The actual macro posted just below does it but not automatically.