Hi,
I'm trying to automate the importing of 4 text files into Excel, but I've so far failed to get my head around appending in VBA!
What I would like to do is have a Macro merge the files called 085.txt, 185.txt, 049.txt & 037.txt into an new file called ratebook.txt.
ratebook.txt would then be imported into excel onto an existing sheet called rate book.
The text files will always be sat in the same folder as the workbook.
I've recorded the macro for the text file import already:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\shaun.winfield\Desktop\085.TXT", Destination _
:=Sheets("rate book").Range("A1"))
.Name = "085"
.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 = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 1, 9, 1, 1, 9)
.TextFileFixedColumnWidths = Array(15, 9, 25, 10, 10)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
Thanks for any advice you can give me!
I'm trying to automate the importing of 4 text files into Excel, but I've so far failed to get my head around appending in VBA!
What I would like to do is have a Macro merge the files called 085.txt, 185.txt, 049.txt & 037.txt into an new file called ratebook.txt.
ratebook.txt would then be imported into excel onto an existing sheet called rate book.
The text files will always be sat in the same folder as the workbook.
I've recorded the macro for the text file import already:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\shaun.winfield\Desktop\085.TXT", Destination _
:=Sheets("rate book").Range("A1"))
.Name = "085"
.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 = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 1, 9, 1, 1, 9)
.TextFileFixedColumnWidths = Array(15, 9, 25, 10, 10)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
Thanks for any advice you can give me!