How to sort cells filtered by two dates
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:
Array formula in F4:
Copy this formula down to F17.
Alternative array formula Excel 2007.
Array formula in F4:
Copy cell F4 and paste it down as far as needed.
Array formula in G4:
Copy cell G4 and paste it down as far as needed.
Alternative array formula Excel 2003.
Array formula in F4:
Copy cell F4 and paste it down as far as needed.
Array formula in G4:
Copy cell G4 and paste it down as far as needed.
Download excel sample file for this tutorial.
sort-cells-between-two-dates
(Excel 97-2003 Workbook *.xls)
Functions in this article:
IF(logical_test;[value_if:true];[value_if_false])
Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE
COUNT(value1;[value2])
Counts the number of cells in a range that contain numbers
SMALL(array,k) returns the k-th smallest row number in this data set.
ROW(reference) returns the rownumber of a reference
VALUE(text) converts a text string that represents a number to a number









December 5th, 2010 at 11:12 am
Verry good article...
One question...how do i extend this sorted list for more cells down?
I`ve already copied the formulas acordling to cells adresses but after row 17 nothing is shown despite the formulas entered there...
Thanks for answer...
December 5th, 2010 at 4:25 pm
@Sorin,
Try changing **all** the 17's in the formulas placed in the first row to the row number for your last piece of data and then copy that down.
December 6th, 2010 at 10:33 pm
Hy,
I`ve already do that...doesn`t work.
Thanks for promptitude..!!
You know other tricks..??
December 7th, 2010 at 7:58 am
Sorin,
Array formula in G4:G17:
=IF(COUNT(SMALL(IF(($A$4:$A$22>D4), VALUE((B4:B22)), ""), ROW()-3))>=ROW()-3, SMALL(IF(($A$4:$A$22 D4), VALUE((B4:B22)), ""), ROW()-3), "")
If your lists doesn´t start on row 3 you also need to change 3's, bolded above.
December 7th, 2010 at 8:17 am
Here is an 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.
December 7th, 2010 at 8:20 am
Here is an 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.
December 8th, 2010 at 10:37 pm
hello,
For the last of your post the sorted list outputs the same result for dates pov also for values. Example 1/10/2010 10 all the way down until reaches 14 rows...then stops..no more values..
December 9th, 2010 at 9:36 am
Sorin,
Select and delete old array formulas in cell range F4:F17 and G4:G17.
Doubleclick cell F4
Copy and paste: =SMALL(IF(G4=$B$4:$B$17, $A$4:$A$17, ""), COUNTIF($F$3:F3, G4)+1)
Press CTRL + SHIFT + ENTER
Copy cell F4 and paste it down as far as needed.
Doubleclick cell G4
Copy and paste: =SMALL(IF(COUNTIF($E$4, ">="&$A$4:$A$17)*COUNTIF($D$4, "<="&$A$4:$A$17), $B$4:$B$17, ""), ROW(A1))
Press CTRL + SHIFT + ENTER
Copy cell G4 and paste it down as far as needed.
December 9th, 2010 at 11:22 pm
With few modification into formula (I just replace some separators like ";" with "," and of course changing array, everything works just fine.
Thank you...
December 10th, 2010 at 7:52 am
Sorin,
I am happy you worked it out!
Sorry about the ";" confusion.
December 23rd, 2011 at 11:14 am
What if i had duplicates in colum C and/or B and i wanted the latest date in colum A for the duplicate to be displayed that corrisponded with this duplicate
January 2nd, 2012 at 2:59 pm
craig,
Array formula in cell E9:
Download excel *.xlsx file
craig.xlsx