Export excel data to text files I have a file that I need the data in each row s
ID: 3565184 • Letter: E
Question
Export excel data to text files
I have a file that I need the data in each row saved to their own text file with specific formatting. I am looking for a way to create the files by running a macro if possible. The below table needs to be converted to two text files. One for each row?. The text filees would be formatted like the text below the table.
I have been doing this by hand before with ssmall list but have recently been getting larger list to do. If their is an easy way to accomplish this I would be thankful forr the help....
Thanks
Number :12368742
PIKE :958
Type :
Size :D
Revision :00
Date :07/08/2013
Title :Air Line
Number :0001
Sheets :0001
Revision ::
Frame :0001
Number :0001
Explanation / Answer
First, yes the use of "0000" forces the output to be 4-digits with leading zeros when needed, so if 23 was in a cell and that format was used, the text output would be 0023.
As for the column problem, you could simply change " To Range("L1").Column" to reference "BA1".
But there's possibly a better way that might even allow you to use the same exact code for any such list regardless of number of columns:
Assumption: Row 1 contains labels for the data in the column and there is a label for all columns of data,and row 1 does not contain any other miscellaneous entries.
Then this line of code automatically finds the last column whether it is A, B, L, AB, or XFC (XFD1 has to be empty)
For colPtr = Range("A1").Column To Cells(1, Columns.Count).End(xlToLeft).Column
and that's it.
Of course we haven't touched on any changes that might need to be made in the Select Case block to format the various columns. I used Range("F1").Column type entries to tell which column colPtr was pointing to for clarity and understanding for you, but could have simply used the actual number, like:
Case 1, 3, 4, 6, 7, 10
instead of
Case Range("A1").Column, Range("C1").Column, Range("D1").Column, _
Range("F1").Column, Range("G1").Column, Range("J1").Column
And you could include all possible columun numbers even out to 53: for the short groups that only weent out to column L, colPtr would never trrigger or even be concerned with 'Case' values of colPtr greateer than 10 and so the code still works in all cases...
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.