Sub Convertir()
Dim c As Range, tablo, i&, x$, dat As Date
Application.ScreenUpdating = False
With ActiveSheet
.Cells.Delete 'RAZ
Set c = .Cells(1)
On Error Resume Next
With Workbooks.Open(ThisWorkbook.Path & "\201912A.csv") 'ouverture du fichier CSV
If Err Then MsgBox "Fichier CSV introuvable !", 48: Exit Sub
.Sheets(1).UsedRange.Copy c 'copier-coller
.Close
End With
On Error GoTo 0
With .UsedRange
.Replace ".", "." 'remplace le point par la virgule et convertit
.Columns(1).EntireColumn.Insert 'insère une colonne
.Cells(1, 0) = "Date"
tablo = .Columns(0).Resize(, 2) 'matrice, plus rapide
For i = 2 To UBound(tablo)
x = tablo(i, 2)
If IsDate(x) Then 'sécurité
dat = CDate(x)
tablo(i, 1) = Mid(dat, 7, 4) & Mid(dat, 4, 2) & Left(dat, 2)
x = Right(dat, 8)
If InStr(x, ":") = 0 Then x = 0
x = Format(Replace(x, ":", ""), "000000")
If Left(x, 1) = "0" Then x = "'" & x 'conserve les zéros non significatifs
tablo(i, 2) = x
End If
Next
With .Columns(0).Resize(, 2)
.NumberFormat = "General" 'format Standard
.Value = tablo 'restitution
End With
End With
.Columns.AutoFit 'ajustement largeurs
End With
End Sub