Sub ImportCsv(destSheet As Worksheet, csvFilePath As String, Optional delimiter As String = ";")
Dim myFso As Object, csvFile As Object, ligne As Long, colonne As Long, tabStr() As String, tabStr2() As String, nbI As Long, i As Long, flag As Boolean
Set myFso = CreateObject("Scripting.FileSystemObject")
Set csvFile = myFso.OpenTextFile(csvFilePath)
While Not csvFile.AtEndOfStream
ligne = ligne + 1
tabStr = Split(csvFile.ReadLine, delimiter)
flag = False: nbI = -1: ReDim tabStr2(0 To 0)
For i = LBound(tabStr) To UBound(tabStr)
If Not flag Then
If Left(tabStr(i), 1) = """" Then
flag = True
tabStr(i) = Right(tabStr(i), Len(tabStr(i)) - 1)
End If
nbI = nbI + 1: ReDim Preserve tabStr2(0 To nbI)
tabStr2(nbI) = tabStr(i)
Else
If Right(tabStr(i), 1) = """" Then
flag = False
tabStr(i) = Left(tabStr(i), Len(tabStr(i)) - 1)
End If
tabStr2(nbI) = tabStr2(nbI) & delimiter & tabStr(i)
End If
Next i
For colonne = LBound(tabStr2) To UBound(tabStr2)
'si l'élément ressemble à une date, la "reformater"
If tabStr2(colonne) Like "??/??/????" Then
destSheet.Range("A" & ligne).Offset(0, colonne) = DateSerial(Right(tabStr2(colonne), 4), Mid(tabStr2(colonne), 4, 2), Left(tabStr2(colonne), 2))
'sinon, copier l'élément tel quel
Else
destSheet.Range("A" & ligne).Offset(0, colonne) = tabStr2(colonne)
End If
Next colonne
Wend
End Sub