How to find the lowest and highest date based on certain value in another column?

In cell E2, copied right to F2 and all copied down :

=AGGREGATE(15-(COLUMN(A1)=2),6,$B$2:$B$9/($A$2:$A$9=$D2),1)

enter image description here


Cell E2 = =MINIFS($B$2:$B$9,$A$2:$A$9,D2)

Cell F2 = =MAXIFS($B$2:$B$9,$A$2:$A$9,D2)

enter image description here