I think I get the picture. Already noticed that I overlooked one of your requirements about the code column needing to be populated.
This will take some vba. I'm thinking of a user defined function. Is that a problem for you?
And I assume that some values in your example should be shifted 1 column to the left? See marked values in the screenshot.
By the way, are you attached to the tables. I mean can they just be ordinary cell matrices? These tables don't add much.
Bookmarks