Bonjour,
A tester aussi.
3 solutions :
1 - Formule de feuille de calcul
=SI(NBCAR(A2)=5;A2;(ENT(A2/10^6)&"/"&ENT(MOD(A2;10^6)/10^4)&"/"&ENT(MOD(A2;10^4)))*1)
2 - Fonction VBA
3 - Procédure VBA (on convertit les cellules en date)
Option Explicit
Public Function Convert_en_Date(Nb) As Date
'convertit en date un nombre au format JMMAAAA
Dim An%, Mois%, Jour%
If Len(Nb) < 7 Then
Exit Function
End If
If IsDate(Nb) Then
Convert_en_Date = Nb
Exit Function
End If
An = Int(Nb Mod 10 ^ 4)
Mois = Int((Nb Mod 10 ^ 6) / 10 ^ 4)
Jour = Int(Nb / 10 ^ 6)
Convert_en_Date = DateSerial(An, Mois, Jour)
End Function
'--------------------------------------------------------------------
Public Sub ConvertDate()
Dim sH As Worksheet
Dim Plage As Range
Dim débLigne As Long, derLigne As Long, i As Long
MsgBox "coucou!"
Application.ScreenUpdating = False
'nom de feuille à adapter suivant classeur
Set sH = Worksheets("VBA")
'numéro ligne pour démarrer la boucle
débLigne = 2
With sH
derLigne = .Range("A" & Rows.Count).End(xlUp).Row
Set Plage = .Range(Cells(débLigne, 1), Cells(derLigne, 1))
For i = débLigne To derLigne Step 1
.Cells(i, 1) = Convert_en_Date(.Cells(i, 1))
Next i
End With
End Sub
Cdlt