Try this ARRAY formula.

=index(b3:b24,small(if(c3:c24="",row(b3:b24)-2),row(b1)))