Import of multiple .CSV files into Excel

A

Ayato

Hi @ll,

I need to build a macro to import data from all .csv files located in
specific directory into an Excel file (on the same sheet)...

I have manage to build a single extract (with 1 file) but I need to b
able to loop threw all files, extract the data, copy and paste and th
bottom of the sheet...

Here is the code of the macro for the single extract :

Sub Macro1()

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Test\test.csv", _
Destination:=Range("A1"))
.Name = "test"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 4
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1
1, 1, 1, 1, 1, 1)
.Refresh BackgroundQuery:=False
End With

End Sub


Please advise,
Thx
Ayat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top