Because the dates are in descending order, I don't feel that you have to include them in the calculation. Assuming that the word "Entry" is in cell A1 the following could be pasted into cell E2 and copied down: =IFERROR(INDEX(A3:A101,AGGREGATE(15,6,(ROW(A3:A101)-ROW(A2))/(C3:C21="y")/(D3:D101<D2),1)),"")