Sub ReadTxtFile()
On Error GoTo Erreur
Dim Chaine As String, Fichier As String, UneLigne As String, i As Integer, f As Integer, T(10000), Lig%, Col%
Cells.ClearContents
Classeur = ThisWorkbook.Name
Fichier = ActiveWorkbook.Path & "\" & "Données.txt"
f = FreeFile
Open Fichier For Input As #f
i = 0
While Not EOF(f)
i = i + 1
Line Input #f, UneLigne
T(i) = UneLigne
Wend
Close #f
With Workbooks(Classeur).Sheets("Feuil1"): .Activate
For Lig = 1 To UBound(T)
tablo = Split(T(Lig), " ")
Col = 1
For i = 0 To UBound(tablo)
If tablo(i) <> "" Then
If Left(tablo(i), 1) = "=" Then tablo(i) = "'" & tablo(i)
.Cells(Lig, Col) = tablo(i)
Col = Col + 1
End If
Next i
Next Lig
End With
Exit Sub
Erreur:
MsgBox "Le fichier de sortie est inaccessible"
End Sub