Hi All;

I have a lot of data (some of which I've shown below) that I'm trying to map in a certain way.

27 1005516
1005510 1005511
1005510 1005514
1005511 1005411
1005511 1005513
1005512 1005510
1005513 1005410
1005515 1005512
1005516 1005515
35 1005640
1005510 1005511
1005510 1005514
1005511 1005411
1005511 1005513
1005512 1005510
1005513 1005410
1005515 1005512
1005640 1005515

The small code (27, 35 etc) is the actual material number, and then the larger codes are ingredients that go into it.
For example, 35 is fed by 1005640, which is fed by 1005515, which is fed by 1005512 which is fed by 1005510 which is fed by both 1005511 & 1005514.

And it's the fact that some levels are fed by multiple ingredients that is causing me an issue in mapping which levels fall into what upper levels. If it was a 1 for 1 mapping, then I could just do a VLOOKUP on each level and find the correct data. This approach get's me about 40% of the way there, but given there are over 5000 products, that doesn't help me that much!

So, is there a formula, a way of working, or some VBA Code that will take the information I have above, and then map it into columns, with the material number first, the second level ingredient next, then third, then 4th etc?

Thanks in Advance.