I have no experience of attempting this so I was hoping one of you guys may have a solution..
Attached is an excel sheet which shows on lines 2-7 how data is likely to be entered onto a spreadsheet. Blank data in a field means no data is necessary, but could be entered.
Lines 11-51 show the files that would have to be output.
Could you have a look at the possibility of producing the 5 output files from the lines 2-7.