Okay, first, I put the Codes in a single row (2), not sure why you had them staggered like that but makes everything difficult.
Second, I created 3 defined namesGreen = B1:E100
Yellow = F1:H100
Red = I1:J100
Then in N6 copied down, this ARRAYED Formula
=MIN(IF(ISNUMBER(INDIRECT(M6)), IF(INDIRECT(M6)>=$O$2, ROW(INDIRECT(M6)))))+7
...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
In O6 (not arrayed)
=INDEX($B$2:$J$2, MATCH($O$2, INDEX(Green, MATCH(N6,$A:$A,0),))+1)
In O7 (not arrayed)
=INDEX($B$2:$J$2,MATCH($O$2,INDEX(Yellow,MATCH(N7,$A:$A,0),))+COLUMNS(Green)+1)
In O8 (not arrayed)
=INDEX($B$2:$J$2, MATCH($O$2, INDEX(Red, MATCH(N8,$A:$A,0),))+1+COLUMNS(Green)+COLUMNS(Yellow))
See attached.
Bookmarks