Excel Sublist Generation
Posted on 2014-03-03
I need a macro that can scan through an excel document, select subsets of info from this excel document and write this info to separate text files.
Specifically, the excel document looks like this:
Column A: name of the text file
Column C: text
Column D: New doc indication - can be "Y" or blank.
The script should:
1. Create a parameter that indicates the folder location where the newly created files will be written to.
2. Scan through the active spreadsheet, starting from the first row and ending with the last row.
3. create a new text file every time it encounters a "Y" value in column D of the currently scanned row. The name of the text file should be value stored in column A of the same row.
4. The context of the text file should be each line stored in Column C starting and including the row that has the "Y" value in row D, and up to and NOT including the either the next occurrence of Y value in Column D, or the end of the spreadsheet. Each line should be written separately - one below another.
For example, scanning of the spreadsheet like the one below should create 3 files A.txt, D.txt and I.txt.:
Name Text New Doc
A IMAGES\001\S-SDF-905-0000001.jpg Y
D IMAGES\001\S-SDF-905-0000004.jpg Y
I IMAGES\001\S-SDF-905-0000009.jpg Y
A.txt should contain
And so on.
Thank you for your help!