One way

=IFERROR(INDEX(Sheet1!A$2:A$1000,SMALL(IF(Sheet1!$B$2:$B$1000="yes",ROW($A$2:$A$1000)-ROW($A$2)+1,""),ROWS($1:1)),COLUMN($A:A)),"")

Enter with Ctrl+Shift+Enter

Copy across and down as far as required.

Resource hungry!!!!