Hi all,

I have a table lisk this:

Type Source Subject Code
L1 doc 12 001
Attachment- L1\doc 12 doc 13 001A
Attachment- L1\doc 12 doc 14 001B
Attachment- L1\doc 12 doc 15 001C
L1 doc 16 002
Attachment- L1\doc 16 doc 17 002A
Attachment- L1\doc 17 doc 18 002B
L1 doc 19 003
Attachment- L1\doc 19 doc 20 003A
Attachment-Attachment- L1\doc 19\doc 20 doc 21 003AA
L1 doc 22 004
L1 doc 23 005
Attachment- L1\doc 23 doc 24 005A
L2 doc 25 006
L2 doc 26 007
L2 doc 27 008
L2 doc 28 009
L2 doc 29 010
L3 doc 30 011
 
 
 
 
L3 doc xxxx 1000
Attachment- L3\doc xxxx doc yyyy 1000A



I need to assign code on column D for each row according to column B, which shows the location path.
The code should increase from 001 to infinity (depends on the number of documents), some documents might contain attachment inside, and I want those attachments to be coded as Parent's code + alphabet A~Z,take doc 13 to 15 from the above table as the example, they should be coded as 001A, 001B and 001C.
And I want to apply the same logic to attachment's attachment as well (there could be over 10 layers), take doc 21 as the example, it is the attachment of attachment, so it is coded as 003AA.

My English is not good, I hope you understand what I mean and thank you all in advance.