ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Generate .txt file from 2 cols of data (https://www.excelbanter.com/excel-programming/281809-generate-txt-file-2-cols-data.html)

mluetkem

Generate .txt file from 2 cols of data
 

What do I need to do to generate a text file from 2 (sometimes not
adjacent) columns of data. Say I have a matrix of date C6:S149.
Column C contains the x data (Time) and columns D thru S contain 16
unique data sets corresponding to the C time column. I want to create
separate .txt files of the combination C & D, C & E, C & F, ..., C & S.
A text file with 2 columns of data, C (Time) and one of D thru F
(data). Thanks.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/


Nikos Yannacopoulos[_4_]

Generate .txt file from 2 cols of data
 
Here's the code you need:

Sub Export_Text_Files()
Dim lin As String
Range("C6").Select

For i = 1 To 16
Open "c:\temp\File" & i & ".txt" For Output As #1
For j = 0 To 143
lin = ActiveCell.Offset(j, 0).Value & ";"
lin = lin & ActiveCell.Offset(j, i).Value & ";"
Print #1, lin
Next
Close #1
Next

End Sub


You can easily change the path and produced file name, as
well as the field separator.

Nikos Y. (nyannaco at in dot gr)
-----Original Message-----

What do I need to do to generate a text file from 2

(sometimes not
adjacent) columns of data. Say I have a matrix of date

C6:S149.
Column C contains the x data (Time) and columns D thru S

contain 16
unique data sets corresponding to the C time column. I

want to create
separate .txt files of the combination C & D, C & E, C &

F, ..., C & S.
A text file with 2 columns of data, C (Time) and one of D

thru F
(data). Thanks.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

.



All times are GMT +1. The time now is 02:55 AM.

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