Sub Fichier_TXT_Import()
Dim Resultat, Chemin As String
Dim Lecture As Integer
Dim Compteur As Variant
Dim T
[B]ActiveSheet.Name = "F1"[/B] [COLOR=SeaGreen]'pour uniformiser mais facultatif[/COLOR]
Cells.Clear
Cells(1, 1).Select
Chemin = ThisWorkbook.Path & "\" & " . "
Chemin = Application.GetOpenFilename
If Chemin = "" Then End
T = Timer
Lecture = FreeFile()
Open Chemin For Input As #Lecture
Application.ScreenUpdating = False
[B]Compteur = 1[/B]
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
[B]Compteur = Compteur + 1[/B]
ActiveSheet.Name = "F" & [B]Compteur[/B]
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
Close
MsgBox "Importation réalisée en " & Format(Timer() - T, "#0") & " seconde(s)"
[COLOR=SeaGreen]Rem suite valable seulement pour la dernière feuille ![/COLOR]
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