4 pièce(s) jointe(s)
EXCEL - VBA queryTables - chargement CSV avec saut ligne (LF) dans les colonnes - Chargement incorrect
Bonjour,
J'ai saisie un jeu de données dans Excel avec dans des cellules des retour ligne (LF)
Pièce jointe 645635
Je l'ai sauvegardé sous CSV (point virgule) Pièce jointe 645639
Pièce jointe 645676
Mais quand je charge le CSV via le code VBA
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| Sub fUploadCSV()
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\monpz\OneDrive\Desktop\data.csv", Destination:=Sheets(3).Range("$D$1"))
.Name = "data"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub |
Les sauts de ligne (LF) sont interprétés comme des lignes supplémentaires -> un chargement incorrect
Pièce jointe 645633
Comment charger le fichier correctement ?