Function testDate(Cellule As Range) As String
'Application.Volatile
Dim oRexp, Match, Matches, MaDate As Date, MesMois, MesMoisBis, I As Integer, MaChaine As String, Jour As Long, An As Long
If Cellule = "" Then Exit Function
MesMois = Array("janvier", "janv.", "janv", "février", "févr.", "févr", "mars", "avril", "avr.", " avr ", "mai", "juin", _
"juillet", "juil.", "juil", "août", "septembre", "sept.", "sept", "octobre", "oct.", "oct", "novembre", "nov.", "nov", "décembre", "déc.", "déc")
MesMoisBis = Array("/01/", "/01/", "/01/", "/02/", "/02/", "/02/", "/03/", "/04/", "/04/", "/04/", "/05/", "/06/", "/07/", "/07/", "/07/", _
"/08/", "/09/", "/09/", "/09/", "/10/", "/10/", "/10/", "/11/", "/11/", "/11/", "/12/", "/12/", "/12/")
MaChaine = Cellule.Value
For I = LBound(MesMois) To UBound(MesMois)
If InStr(1, Cellule.Value, MesMois(I), vbTextCompare) > 0 Then
MaChaine = Trim(Replace(MaChaine, MesMois(I), MesMoisBis(I)))
MaChaine = Replace(MaChaine, " /", "/")
MaChaine = Replace(MaChaine, "/ ", "/")
Exit For
End If
Next I
Set oRexp = CreateObject("vbscript.regexp")
With oRexp
.Global = True
.Pattern = "(\b\d{1})(/\d{2}/\d{4})"
Set Matches = .Execute(MaChaine)
MaChaine = .Replace(MaChaine, "0$1$2")
.Pattern = "(\b\s)(\d{1})(/\d{2}/)((?:0|1|2)[0-9])"
Set Matches = .Execute(MaChaine)
MaChaine = .Replace(MaChaine, "0$2$320$4")
.Pattern = "(\b\s)(\d{1})(/\d{2}/)((?:3|4|5|6|7|8|9)[0-9])"
Set Matches = .Execute(MaChaine)
MaChaine = .Replace(MaChaine, "$10$2$319$4")
End With
With oRexp
.Pattern = "((0[1-9]|[12]\d|3[01])/(0[13578]|1[02])|(0[1-9]|[12]\d|30)/(0[469]|11))/(190[1-9]|19[1-9]\d|(20|21)\d\d)|(0[1-9]|[1]\d|[2][0-8])/02/(190[1-9]|19[1-9]\d|(20|21)\d\d)|29/02/((190|210)[48]|(19|20|21)([13579][26]|[2468][048])|200[048])"
.Global = True
Set Matches = .Execute(MaChaine)
If .test(MaChaine) = True Then testDate = CDate(Right(MaChaine, 10)) Else testDate = "Date non valide"
End With
End Function