Try array formula:
=IFERROR(INDEX(Names!$K$2:$K$185, SMALL(IF(("Y"=Names!$I$2:$I$185)+("YS"=Names!$I$2: $I$185), ROW($E$3:$E$186)-MIN(ROW($E$3:$E$186))+1, ""), ROW(A1))),"")
You'll have to replace the Names! references to your actual data references.
|