Dear Gentlemen,
I am working on a VBA program.
I am looking for more better / easy program in VBA only which can IMPORT... 30 csv files (say, sub files) and merges all data into one xls file (say, main file having sheet1: details of file names whom to import ... and sheet2: merged data exactly one after another starting from second row with additional column showing "sub file name" from which data was imported.
[vba]
Private sub mrg()
With ActiveSheet.QueryTables.Add(Connection:= "TEXT;C:\abc.csv", Destination:=Range("A2"))
.Name = "abc"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 2
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
[/vba]