Option Explicit 'd'après Bernie Detrick sur .... et Kjin sur XLD ;-)
Sub Fichier_TXT_Import()
Dim Resultat, Chemin As String
Dim Lecture As Integer
Dim Compteur As Variant
Dim T
Cells.Clear
Cells(1, 1).Select
Chemin = ThisWorkbook.Path & "\" & "Importe_TXT.Ficihier_Test.txt"
'Chemin = Application.GetOpenFilename
If Chemin = "" Then End
T = Timer
Lecture = FreeFile()
Open Chemin For Input As #Lecture
Application.ScreenUpdating = False
Compteur = 1
Do While Seek(Lecture) <= LOF(Lecture)
Application.DisplayAlerts = False
Line Input #Lecture, Resultat
Application.DisplayAlerts = True
ActiveCell.Value = Resultat
ActiveCell.TextToColumns , DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, Comma:=True
If ActiveCell.Row = 65536 Then
ActiveWorkbook.Sheets.Add
ActiveSheet.Name = "F2"
Else
ActiveCell.Offset(1, 0).Select
End If
Compteur = Compteur + 1
Loop
Close
MsgBox "Importation réalisée en " & Format(Timer() - T, "#0") & " seconde(s)"
Range("A1:L1").AutoFilter
With Columns("A:L")
.Sort Key1:=Range("F2"), Order1:=xlAscending, Header:=xlGuess
.Font.Name = "Tahoma"
.Font.Size = 8
.Columns.AutoFit
End With
Range("A1").Select
Application.ScreenUpdating = True
End Sub