Hi:
=AGGREGATE(15,6,(ROW($A$2:$A$31)-ROW($A$2)+1)/($A$2:$A$31=E2),1)-AGGREGATE(15,6,(ROW($A$2:$A$31)-ROW($A$2)+1)/($A$2:$A$31=D2),1), This part can be removed and the formula can be shortened by =AGGREGATE(15,6,ROW($A$1:$A$31)/($A$2:$A$31=E2),1)-AGGREGATE(15,6,ROW($A$1:$A$31)/($A$2:$A$31=D2),1)
Thanks