You're welcome.

Let me split it into its component parts.

AGGREGATE(15,6,ROW(Sheet2!$A$4:$A$9999)-ROW(Sheet2!$A$3)

/

(Sheet2!$B$4:$B$9999="Yes")

,ROW()-ROW($A$1)

AGGREGATE has many options. 15 is the SMALL option and 6 says ignore errors.

You can use the SMALL option to look for the kth smallest in a column of numbers but here I'm using the ROW(Sheet2!$A$4:$A$9999) to give me row numbers 4 to 9999 and I subtract ROW(Sheet2!$A$3) to give the correct index for INDEX(Sheet2!$A$4:$A$9999.

The (Sheet2!$B$4:$B$9999="Yes") will return a logical 1 when it finds a "Yes" in column B or logical 0 if not. That divided into the row numbers I'm searching will give a #DIV/0 error if logical zero which the 6 option ignores. If it's a logical 1 then the row divided by 1 returns the row number which the INDEX then selects.

The last option of AGGREGATE is the kth value so as we're using the SMALL option then 1 returns the lowest value (row), 2 returns the second lowest row, etc. So ROW()-ROW($A$1) starting in row 2 is 2-1 so I get the first, then in the next row 3-1 gives me the second, etc.