ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Searching a txt file for splitting into different worksheets (https://www.excelbanter.com/excel-programming/289763-searching-txt-file-splitting-into-different-worksheets.html)

Randy Reese

Searching a txt file for splitting into different worksheets
 
Is it possible to write code that will take a 100 page txt file that has
several different fixed width sections and send them to different
worksheets. The Text file looks something like this:



Report for 1-19-2004
Section A
xxx xxxx xx xxxxxx xxxx xxxxxx xxx
xxx xxxx xx xxxxxx xxxx xxxxxx xxx
xxx xxxx xx xxxxxx xxxx xxxxxx xxx
end of section

Report for 1-19-2004
Section B
xxxxxx xxxx xxxx xxxxxxxxxx
xxxxxx xxxx xxxx xxxxxxxxxx
xxxxxx xxxx xxxx xxxxxxxxxx
xxxxxx xxxx xxxx xxxxxxxxxx
end of section

Report for 1-19-2004
Section C
xxx xxx xxx xxxxxx xxxx xxxxxxx xxx xxx
xxx xxx xxx xxxxxx xxxx xxxxxxx xxx xxx
xxx xxx xxx xxxxxx xxxx xxxxxxx xxx xxx
page break

Report for 1-19-2004
Section C
xxx xxx xxx xxxxxx xxxx xxxxxxx xxx xxx
xxx xxx xxx xxxxxx xxxx xxxxxxx xxx xxx
xxx xxx xxx xxxxxx xxxx xxxxxxx xxx xxx
end of section



Tom Ogilvy

Searching a txt file for splitting into different worksheets
 
Yes, you would just look for the word Section in the line you read in to
separate the sections.

You would want to do a sequential read:

http://support.microsoft.com/support...eio/fileio.asp
File Access with Visual Basic® for Applications


--
Regards,
Tom Ogilvy

"Randy Reese" wrote in message
ink.net...
Is it possible to write code that will take a 100 page txt file that has
several different fixed width sections and send them to different
worksheets. The Text file looks something like this:



Report for 1-19-2004
Section A
xxx xxxx xx xxxxxx xxxx xxxxxx xxx
xxx xxxx xx xxxxxx xxxx xxxxxx xxx
xxx xxxx xx xxxxxx xxxx xxxxxx xxx
end of section

Report for 1-19-2004
Section B
xxxxxx xxxx xxxx xxxxxxxxxx
xxxxxx xxxx xxxx xxxxxxxxxx
xxxxxx xxxx xxxx xxxxxxxxxx
xxxxxx xxxx xxxx xxxxxxxxxx
end of section

Report for 1-19-2004
Section C
xxx xxx xxx xxxxxx xxxx xxxxxxx xxx xxx
xxx xxx xxx xxxxxx xxxx xxxxxxx xxx xxx
xxx xxx xxx xxxxxx xxxx xxxxxxx xxx xxx
page break

Report for 1-19-2004
Section C
xxx xxx xxx xxxxxx xxxx xxxxxxx xxx xxx
xxx xxx xxx xxxxxx xxxx xxxxxxx xxx xxx
xxx xxx xxx xxxxxx xxxx xxxxxxx xxx xxx
end of section






All times are GMT +1. The time now is 07:01 AM.

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