Author: Oscar Cronquist Article last updated on February 02, 2018

Question: I have a list containg dates and values.
How do I sort values between two specific dates?

Answer: Yellow cells are input cells. The gray area is the sorted value list.

### Array formula in G4:G17:

=IF(COUNT(SMALL(IF((\$A\$4:\$A\$17<E4)*(\$A\$4:\$A\$17>D4), VALUE((B4:B17)), ""),ROW()-3))>=ROW()-3, SMALL(IF((\$A\$4:\$A\$17<E4)*(\$A\$4:\$A\$17>D4), VALUE((B4:B17)),""), ROW()-3), "") + Ctrl + Shift +  Enter

### Array formula in F4:

=IF(G4<>"", SMALL(IF(G4=\$B\$4:\$B\$17, \$A\$4:\$A\$17, ""),SUM(IF(G4=\$G\$4:G4, 1, 0))), "") + Ctrl + Shift + Enter.

Copy this formula down to F17.

### Alternative array formula Excel 2007.

Array formula in F4:

=SMALL(IF(G4=\$B\$4:\$B\$17, \$A\$4:\$A\$17, ""), COUNTIF(\$F\$3:F3, G4)+1) + CTRL + SHIFT + ENTER.

Copy cell F4 and paste it down as far as needed.

Array formula in G4:

=SMALL(IF(COUNTIFS(\$E\$4, ">="&\$A\$4:\$A\$17, \$D\$4, "<="&\$A\$4:\$A\$17), \$B\$4:\$B\$17, ""), ROW(A1)) + CTRL + SHIFT + ENTER.

Copy cell G4 and paste it down as far as needed.

### Alternative array formula Excel 2003.

Array formula in F4:

=SMALL(IF(G4=\$B\$4:\$B\$17, \$A\$4:\$A\$17, ""), COUNTIF(\$F\$3:F3, G4)+1) + CTRL + SHIFT + ENTER.

Copy cell F4 and paste it down as far as needed.

Array formula in G4:

=SMALL(IF(COUNTIF(\$E\$4, ">="&\$A\$4:\$A\$17)*COUNTIF(\$D\$4, "<="&\$A\$4:\$A\$17), \$B\$4:\$B\$17, ""), ROW(A1)) + CTRL + SHIFT + ENTER.

Copy cell G4 and paste it down as far as needed.