Hi,
1] Change your cell A2:A18 from text value into numeric value.
2] Count non blank value, in C23 array formula copy down :
=MAX(COUNTIF(OFFSET(OFFSET(B$1,MATCH(A23,$A$1:$A$18,0)-2,),ROW(INDIRECT("1:"&COUNTIF(A$2:A$18,A23))),,,6),">0"))
p.s. Array formula must confirm enter in pressing CTRL+SHIFT+ENTER 3 keystrokes together.
3] Or, this non- array formula instead :
=AGGREGATE(14,,COUNTIF(OFFSET(OFFSET(B$1,MATCH(A23,$A$1:$A$18,0)-2,),ROW(INDIRECT("1:"&COUNTIF(A$2:A$18,A23))),,,6),">0"),1)
Regards