close

I have multiple text files that I want to load into a microsoft excel
spread sheet. Here is how it goes, I have four folders each contains
about 20 data sets. I will have more, is there any way I can write a
macro to load these text files starting at row 19 into one worksheet.
Each data set contains two columns and about 250 rows. The file names
in a folder go up by experiment and number so it goes emi1.txt,
emi2.txt....then emi(2)1.txt, emi(2)2.txt and so on and so forth. If I
can even load one folder at a time that would be great, I tried
recording a macro but I would have to copy and paste and change the
file name and target cell over 60 times. Is there anyway I can do this
easily, and if possible have the filename be located on the first row?

Thanks
BobYou might take a look at Jim Cone's free Add-in called ListFiles......it
won't do the whole job for you, but it might make it a lot easier......

Available at www.realezsites.com/bus/primi.../products.php?

Vaya con Dios,
Chuck, CABGx3
gt; wrote in message oups.com...
gt; I have multiple text files that I want to load into a microsoft excel
gt; spread sheet. Here is how it goes, I have four folders each contains
gt; about 20 data sets. I will have more, is there any way I can write a
gt; macro to load these text files starting at row 19 into one worksheet.
gt; Each data set contains two columns and about 250 rows. The file names
gt; in a folder go up by experiment and number so it goes emi1.txt,
gt; emi2.txt....then emi(2)1.txt, emi(2)2.txt and so on and so forth. If I
gt; can even load one folder at a time that would be great, I tried
gt; recording a macro but I would have to copy and paste and change the
gt; file name and target cell over 60 times. Is there anyway I can do this
gt; easily, and if possible have the filename be located on the first row?
gt;
gt; Thanks
gt; Bob
gt;
In another forum I found this macro and I don't know if it will work
for what I want to do but I thought someone who has a little more
expertise might know.

Thanks

Sub opentext()

Dim i As IntegerFor i = 1 To 10000

Workbooks.opentext Filename:=quot;D:\VB\10000quot; amp; i amp; quot;.outquot;, _ /The text
file can be name as 10001, 10002,....
Origin:=xlMSDOS, _
StartRow:=1, _
DataType:=xlDelimited, _
ConsecutiveDelimiter:=True, _
Space:=True

Next i

End Sub

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()