Hi Guys,
I want to apply an autofilter using VBA which sorts my data between dates.
The dates will vary so they have been declared as variables, which the user will be prompted to input via a message box.
The trouble is that the variables can be input into the autofilter code but it is then read as a plain date, it doesnt know that i want data greater than one date and less another.
When i add these symbols before my variables > < as seen below, it cannot interpret them. If i do this >"startdate" then it mistakes my variable as a text criteria.
How do i go about solving this problem, my brain is at wits end?
Code
Sub DATESEARCH()
Dim LastRow As Long
Dim startdate As String
Dim enddate As String
Dim Pasterange As Range, sht3
Set sht1 = Sheets("data1")
Set sht2 = Sheets("data2")
Set sht3 = Sheets("data")
'last row number of column to be filtered'
LastRow = sht3.Range("c65536").End(xlUp).Row
'Input Start Date'
Msg = "Start Date - DD/MM/YY"""
startdate = InputBox(Msg)
If startdate = "" Then Exit Sub
'Input End Date'
Msg = "End Date - DD/MM/YY"""
enddate = InputBox(Msg)
If enddate = "" Then Exit Sub
Columns("c:c").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=>startdate, Operator:=xlAnd, _
Criteria2:=<enddate
End Sub
Display More
Thanks,
Mark :rambo: