1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
   | Sub Dates_Formater()
Dim LaCell As Range, LaDate, Result, i As Integer, DerLigne As Integer, Plage As Range
Dim LeTableau, Annee, séparateur
Annee = Array("", "JAN", "FEV", "MAR", "AVR", "MAI", "JUN", "JUL", "AOU", "SEP", "OCT", "NOV", "DEC")
DerLigne = Range("A1").SpecialCells(xlCellTypeLastCell).Row
Set Plage = Range(Cells(1, 1), Cells(DerLigne, 1))
    For Each LaCell In Plage
        LaDate = LaCell.Value
        If InStr(LaDate, "-") Then
                séparateur = "-"
            ElseIf InStr(LaDate, ".") Then
                séparateur = "."
            ElseIf InStr(LaDate, "/") Then
                séparateur = "/"
            ElseIf InStr(LaDate, " ") Then
                séparateur = " "
        End If
        For i = 1 To 12
            If LCase(LaCell.Value) Like "*" & séparateur & LCase(Annee(i)) & séparateur & "*" Then
                Result = Left(LaDate, InStr(LaDate, Annee(i)) - 1) & Right("0" & CStr(i), 2) & _
                Right(LaDate, Len(LaDate) - InStr(LaDate, Annee(i) - 1) - Len(LaDate))
                LaDate = Result
                Exit For
            End If
        Next
        Result = ""
        LeTableau = Split(LaDate, séparateur)
        For i = 1 To UBound(LeTableau)
            Result = Result & " " & LeTableau(i)
        Next
        'Juste pour montrer qu'on peut faire n'importe quoi...
        '... et passer d'un format à un autre
        LaCell = Format(Result, "dddd dd mmmm yyyy")
        Debug.Print LaCell.Value
    Next
End Sub |