in reply to Nested loops?
It would be very useful if you provided sample input data for those, much in the way stevieb dit it in his answer.