I have a spreadsheet here: https://docs.google.com/spreadsheets/d/1zh1EvjMqOnQVx4KAfHUEWT8_kCst1MOu0cJpUHb39q4/edit?usp=sharing
I am trying to have column I populate with the age that I have selected in the 2nd row of column C (per race). The formula I have now accommodates for each age, but isn't able to accommodate for the group that's called "LIT" in row 68 (Race 5).
Note - it also works for a special case where it's an "All star" race. see Row 243
=ARRAYFORMULA(IF(LEN(D3:D866),vlookup(row(A3:866)+REGEXMATCH(C3:C866&E3:E866,"^RACE.+\d$"),SORT({row(H3:H866)*(REGEXMATCH(C3:C866&E3:E866,"\d+s")),iferror(REGEXEXTRACT(C3:C866&E3:E866,"\d+s"))}),2,2)&" "&D3:D866&"s",))