Try these Array Formulas which requires confirmation with
Ctrl+Shift+Enter instead of just Enter.
In D2
=IF(INDEX($K$2:$K$38,MATCH($C2,$J$2:$J$38,0))=1,C2,INDEX($J$2:$J$38,MIN(IF($J$2:$J$38>C2,IF($K$2:$K$38=1,ROW($J$2:$J$38)-ROW($J$2)+1)))))
then drag down to D3.
In D4
=IF(INDEX($K$2:$K$38,MATCH($C4,$J$2:$J$38,0))=1,C4,INDEX($J$2:$J$38,MAX(IF($J$2:$J$38<C4,IF($K$2:$K$38=1,ROW($J$2:$J$38)-ROW($J$2)+1)))))
then drag down to D5.
Bookmarks