0

The user made the last request, and could you please help me? When the user types the "Date From" and "Date to", the "/" should start appearing as long as the user types I am trying via the code below

This is the code that I am using to try to do it, but I am not getting this outcome

Sub TableFilt1()
Dim ToDate      As Date, FrDate As Date
With Sheet6
    LastRow = .Range("E99999").End(xlUp).Row
    
    If .Range("M5").Value > .Range("N5").Value Then
        MsgBox "Invalid Date Range.""Date to"" must be greater than ""Date from"""
        Call ClearFilt
        .Range("A1").Select
        Exit Sub      
    End If    
    If .Range("M5").Value = "From Date" Then FrDate = "01/05/2018" Else: FrDate = .Range("M5").Value
    If .Range("N5").Value = "To Date" Then ToDate = "01/04/2021" Else: ToDate = .Range("N5").Value
    With .Range("E6:AU" & LastRow)
        .AutoFilter Field:=9, _
                    Criteria1:=">=" & Format(Left(FrDate, 2), "yyyy-mm-dd") & "/" & Format(Mid(FrDate, 3, 2), "yyyy-mm-dd") & "/" & Format(Right(FrDate, 2), "yyyy-mm-dd"), _
                    Operator:=xlAnd, _
                    Criteria2:="<=" & Format(Left(ToDate, 2), "yyyy-mm-dd") & "/" & Format(Mid(ToDate, 3, 2), "yyyy-mm-dd") & "/" & Format(Right(Date, 2), "yyyy-mm-dd")
    End With
End With
End Sub
braX
  • 11,506
  • 5
  • 20
  • 33

0 Answers0