Link to home
Start Free TrialLog in
Avatar of cyber-33
cyber-33Flag for United States of America

asked on

Excel Sublist Generation

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
B            IMAGES\001\S-SDF-905-0000002.jpg      
C            IMAGES\001\S-SDF-905-0000003.jpg      
D            IMAGES\001\S-SDF-905-0000004.jpg      Y
E            IMAGES\001\S-SDF-905-0000005.jpg      
F            IMAGES\001\S-SDF-905-0000006.jpg      
G            IMAGES\001\S-SDF-905-0000007.jpg      
H            IMAGES\001\S-SDF-905-0000008.jpg      
I            IMAGES\001\S-SDF-905-0000009.jpg      Y
J            IMAGES\001\S-SDF-905-0000010.jpg      
K            IMAGES\001\S-SDF-905-0000011.jpg      
L            IMAGES\001\S-SDF-905-0000012.jpg      

A.txt should contain
IMAGES\001\S-SDF-905-0000001.jpg
IMAGES\001\S-SDF-905-0000002.jpg
IMAGES\001\S-SDF-905-0000003.jpg

And so on.

Thank you for your help!
ASKER CERTIFIED SOLUTION
Avatar of Ejgil Hedegaard
Ejgil Hedegaard
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cyber-33

ASKER

Thank you!