Sub AutoFilterWithDate()
Dim WS As Worksheet
Dim x As Date
Dim y As Date
Set WS = Sheets('Planning')
On Error GoTo Out
x = CDate(InputBox('date Début ex:01/01/2005', 'Date From: ', '01/05/2005'))
y = CDate(InputBox('date Fin ex:22/01/2005', 'Date TO: ', '05/05/2005'))
WS.Range('A1').AutoFilter Field:=2, Criteria1:='>=' & Format(x, 'mm/dd/yy'), Operator:=xlAnd, Criteria2:='<=' & Format(y, 'mm/dd/yy')
Exit Sub
Out:
If Err = 13 Then
MsgBox 'Veuiller saisir une Date Valide', vbCritical, 'Alert !!!'
If WS.FilterMode = True Then WS.ShowAllData
Else
MsgBox 'Erreur non Gérée ' & Err.num & ' ' & Err.Description
End If
End Sub