Sub test3()
fichier = Application.GetOpenFilename("Text Files (*.txt), *.txt", 1, "ouvrir un fichier")
If fichier = "" Then Exit Sub
x = InputBox("tapez les numero de colonnes séparée par une virgule", "liste des colonnes")
If x <> "" Then colonnes = Split(x, ",")
With ActiveSheet
With .QueryTables.Add(Connection:="TEXT;" & fichier, Destination:=Range("$A$1"))
.Name = "bdd"
.FieldNames = True
.PreserveFormatting = True
.RefreshStyle = xlInsertDeleteCells
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileDecimalSeparator = "."
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
.Delete
End With
tbl = Application.Index(.Cells(1).CurrentRegion.Value, Evaluate("ROW(" & 1 & ":" & .Cells(1).CurrentRegion.Rows.Count & ")"), colonnes)
.Cells(1).CurrentRegion.ClearContents
.Cells(1).Resize(UBound(tbl), UBound(tbl, 2)) = tbl
End With
End Sub