Sub Import_donnees()
Dim Tablo, Tablo2$, Tablo3$(), x&, y&, z&, i&, Nom_Fichier$
With Application.FileDialog(msoFileDialogFilePicker)
.ButtonName = "Lire"
.AllowMultiSelect = False
.Title = "Choisissez le fichier à importer"
.Filters.Clear
.Filters.Add "Extraction données", "*.txt; *.txt", 1
.Show
If .SelectedItems.Count > 0 Then
Nom_Fichier = .SelectedItems(1)
Else
MsgBox "Aucun fichier sélectionné", vbOKOnly + vbInformation, "Information"
Exit Sub
End If
End With
Workbooks.OpenText Filename:=Nom_Fichier, Origin:=xlMSDOS, _
StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), Array(4, _
9), Array(14, 2)), TrailingMinusNumbers:=True
Columns("B:B").Replace What:="OK", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula
Tablo = Range("B1:B" & Range("B" & Rows.Count).End(xlUp).Row).Value2
y = LBound(Tablo): z = UBound(Tablo)
For x = y To z
If (InStr(1, Tablo(x, 1), ",") > 0 Or InStr(1, Tablo(x, 1), ".") > 0 Or IsNumeric(Tablo(x, 1))) And (IsNumeric(Left(Tablo(x, 1), 1)) Or Left(Tablo(x, 1), 1) = "." Or Left(Tablo(x, 1), 1) = ",") Then
Tablo2 = Tablo2 & Tablo(x, 1)
End If
If Not Tablo2 = "" Then If Left(Tablo(x, 1), 1) = "P" And IsNumeric(Mid(Tablo(x, 1), 2, 1)) Then Tablo2 = Tablo2 & ","
Next x
Columns("A:B").ClearContents
Columns("A:C").NumberFormat = "@"
Tablo = Split(Tablo2, ",")
ReDim Tablo3(1 To Application.WorksheetFunction.RoundUp((UBound(Tablo) - LBound(Tablo) + 1) / 3, 0), 1 To 3)
i = LBound(Tablo)
For x = LBound(Tablo) To UBound(Tablo) Step 3
i = i + 1
Tablo3(i, 1) = Tablo(x)
Tablo3(i, 2) = Tablo(x + 1)
Tablo3(i, 3) = Tablo(x + 2)
Next x
Range("A1:C" & UBound(Tablo3, 1)).Value2 = Tablo3
End Sub