Importation de plusieurs csv

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

lblanc18

XLDnaute Nouveau
Bonjour,
je cherche à importer plusieurs fichiers csv dans une feuille excel mais je me retrouve avec un probleme de taille : les nouvelles importations me decalent celles d'avant et j'ai une ligne identique
voici le code que j'utilise.
If Feuille <> "" Then
Set Origine = Sheets("Import-" & Feuille)
Origine.Activate
toto = Origine.UsedRange.Rows.Count
'Range("A1").Select
'Range("A" & toto + 1).Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & objFile.Path, _
Destination:=Range("A" & toto + 1))
.Name = objFile.Name
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
'.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End If

Merci pour votre aide
 
Re : Importation de plusieurs csv

a priori j'ai trouve une astuce (avec une correction aussi)
If Feuille <> "" Then
Set Origine = Sheets("Import-" & Feuille)
Origine.Activate
If Origine.UsedRange.Rows.Count = 1 Then
Set insertRange = Range("A" & Origine.UsedRange.Rows.Count)
nbLigne = 1
Else
Set insertRange = Range("A" & Origine.UsedRange.Rows.Count + 1)
nbLigne = 2
End If
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & objFile.Path, _
Destination:=insertRange)
.Name = objFile.Name
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = nbLigne
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.Refresh BackgroundQuery:=False
End With
End If
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

  • Question Question
Microsoft 365 CSV en EXCEL
Réponses
1
Affichages
99
Retour