VBA CSV --> Excel / Erreur de script ?

Fermé
wolfiz1999 Messages postés 2 Date d'inscription jeudi 20 mai 2010 Statut Membre Dernière intervention 5 novembre 2010 - 20 mai 2010 à 14:44
Bonjour,

Un problème avec mon script, j'aimerai faire un import de plusieurs CSV l'un en dessous de l'autres dans une même sheet...

Le problème c'est qu'au lieu de le mettre l'un en dessous de l'autre, il me le mets l'un a coté de l'autre et ça , ca ne m'arrange pas pour filtrer et tout cela

J'ai fait une erreur dans mon script (je travaille avec Excel 2003)

Sub MySWR_Import()
Dim strFile As String, wb As Workbook, strPath As String
strPath = "C:\data\temp\" 'amend directory as appropriate
strFile = Dir(strPath & "SWR*.csv") ' amend extension as appropriate
If strFile <> "" Then
Do


'process wb - ie extract data
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" + strPath + strFile, Destination:=Sheets("SWR").Range("A1"))
.Name = strFile
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = False
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = ";"
.TextFileColumnDataTypes = Array(1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With





strFile = Dir 'next workbook in directory (if there is one)
Loop While strFile <> "" 'terminates when no other workbooks found
End If
End Sub


Merci pour votre aide



A voir également: