JR_Chicago
New Member
- Joined
- Apr 20, 2010
- Messages
- 23
Hey folks... I have two tab delimited text files that I'm trying to read into an Excel workbook which I've already created...
I've been unable to find the code for reading a text file into an existing workbook, rather, the book I am using, "Writing Excel Macros with VBA" by Steven Roman only has examples for loading text files as NEW workbooks.
I've been successful in loading the text files as new workbooks using the following code:
As I said, when I run this macro from the current workbook it opens a new instance of Excel and populates the values from the text file in that workbook.
I want to read both text files into my current workbook.
Anyone know how to do that?
Thanks.
I've been unable to find the code for reading a text file into an existing workbook, rather, the book I am using, "Writing Excel Macros with VBA" by Steven Roman only has examples for loading text files as NEW workbooks.
I've been successful in loading the text files as new workbooks using the following code:
Code:
Sub ReadInTextFiles()
Workbooks.OpenText _
Filename:="E:\New Folder\__New_Product_File.txt", _
Origin:=xlWindows, _
StartRow:=1, _
DataType:=xlDelimited, _
TextQualifier:=xlTextQualifierNone, _
ConsecutiveDelimiter:=True, _
Tab:=True, _
FieldInfo:=Array(Array(1, 2), Array(2, 1), Array(3, 1), Array(4, 1))
End Sub
As I said, when I run this macro from the current workbook it opens a new instance of Excel and populates the values from the text file in that workbook.
I want to read both text files into my current workbook.
Anyone know how to do that?
Thanks.