ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   export excel colonm to a single text file (https://www.excelbanter.com/excel-discussion-misc-queries/214306-export-excel-colonm-single-text-file.html)

[email protected]

export excel colonm to a single text file
 
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

Gary''s Student

export excel colonm to a single text file
 
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
--
Gary''s Student - gsnu2007k


" wrote:

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



All times are GMT +1. The time now is 10:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com