export excel colonm to a single text file

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
 
G

Gary''s Student

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top