I am applying an auto filter with specific date ranges using VBA and run the below code. The issue is, each time when I apply the auto filter, date is in the US format (MM/DD/YYYY). On my report, the dates are in the UK format (DD/MM/YYYY) and I need to use this format for my reporting. My code is as below:
Dim sdt As Date
Dim edt As Date
sdt = CDate(Application.InputBox("Choose Start date.", Type:=2))
edt = CDate(Application.InputBox("Choose End date.", Type:=2))
ActiveSheet.Range("$A:$C").AutoFilter Field:=3, Criteria1:=">=" & sdt,
Operator:=xlAnd, Criteria2:="<=" & edt
I tried to modify my code slightly but without success:
ActiveSheet.Range("$A:$C").AutoFilter Field:=2, Criteria1:=">=" & CLng(Range("sdt").Value), Criteria2:="<=" & CLng(Range("edt").Value)
or
ActiveSheet.Range("$A:$C").AutoFilter Field:=2, Criteria1:=">=" & CDbl(sdt) Operator:=xlAnd, Criteria2:="<=" & CDbl(edt)
Can you please advise hot to modify my code to apply an auto filter in the UK date format (DD/MM/YYYY)?
Thanks in advance.