et oui je viens de verifier
regarde arriver vers 1340 dans le fichier txt
autrement dit tu n'y peux rien c'est pas excel c'est ton fichier txt
meme manuellement quand on regarde le format cellule il est bon "jj/mm"aaaa"
encore une BDD pourri
Regarde la pièce jointe 1063779
Sub test()
Dim tout As String, x$, fichier As String, tbl, colonnes
Application.ScreenUpdating = False
fichier = "C:\Users\polux\DeskTop\bdd.txt"
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, ",")
x = FreeFile: Open fichier For Binary Access Read As #x: tout = String(LOF(x), " "): Get #x, , tout: Close #x
For i = 20 To Right(Year(Date) + 1, 2): tout = Replace(tout, "/" & i, "/20" & i): Next
With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}"): .SetText tout: .PutInClipboard: End With
With Sheets(1).Cells(1, 1) 'Cells(Rows.Count, 1).End(xlUp).Offset(1)
.Parent.Activate
.CurrentRegion.Clear
.EntireColumn.NumberFormat = "mm/dd/yyyy"
.Select
ActiveSheet.Paste
DoEvents
tbl = Application.Index(.CurrentRegion.Value, Evaluate("ROW(" & 1 & ":" & .CurrentRegion.Rows.Count & ")"), colonnes)
.CurrentRegion.ClearContents
.EntireColumn.NumberFormat = "m/d/yyyy"
.Resize(UBound(tbl), UBound(tbl, 2)) = tbl
'.EntireColumn.NumberFormat = "dd/mm/yyyy"
.EntireColumn.HorizontalAlignment = xlRight
End With
End Sub
Bonjour le fil
Ce souci n'apparaissait pas avec QueryTable*, non ?
(C'est peut-être plus long, mais sans souci, non ?)
*: macro du message#47
...
NB: Et tu ne sais toujours pas quelle proposition tu vas retenir au bout de 81 posts ?
Sub test3()
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\polux\Desktop\bdd.txt", 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
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileDecimalSeparator = "."
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
.Delete
End With
End Sub