export excel colonm to a single text file

  • Thread starter Thread starter philippe.zizzari
  • Start date Start date
P

philippe.zizzari

hello,

I try to export data from excel file, i would like to export multiple
colonm, each colonm in a separate text file with. Is it possible to
specify the names of the export file in the first row of each colonm

thank you very much for your help

Phil
 
Hi Phil:

Here is some sample data for columns A thru C:

c:\test\birds.txt c:\test\animals.txt c:\test\flowers.txt
sparrow dog rose
robin cat lily
quail mouse violet
hawk flea snapdragon
rat
elephant
moose


The first row is the full filespec (path & name). Here is a very simple
macro:

Sub Column2File()
' gsnuxx
Set fs = CreateObject("Scripting.FileSystemObject")
For i = 1 To 3
n = Cells(Rows.Count, i).End(xlUp).Row
fspec = Cells(1, i).Value
Set a = fs.CreateTextFile(fspec, True)
For j = 2 To n
a.WriteLine (Cells(j, i).Value)
Next
a.Close
Set a = Nothing
Next
Set fs = Nothing
End Sub
 
Back
Top