In a previous article How to sort cells filtered by two dates I came up with a solution on how to sort cells containing numbers, filtered by two dates. In this article I will sort cells containing text values.

Chandoo at Pointy haired Dilbert posted a great article Sorting Text in Excel using Formulas that has inspired me.

COUNTIF(range,criteria)
Counts the number of cells within a range that meet a given condition

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

Here is the formula in G4:G17

=IF(SUM(IF((\$A\$4:\$A\$17<E4)*(\$A\$4:\$A\$17>D4),1,0))>=ROW()-3,INDEX(C4:C17, MATCH(SMALL(IF((\$A\$4:\$A\$17<E4)*(\$A\$4:\$A\$17>D4), COUNTIF(\$C\$4:\$C\$17,"<"&\$C\$4:\$C\$17)+1,""),ROW()-3), COUNTIF(\$C\$4:\$C\$17,"<"&\$C\$4:\$C\$17)+1,0)),"") + Ctrl + Shift + Enter

sort-text-cells-between-two-dates
(Excel 97-2003 Workbook *.xls)

MATCH(lookup_value;lookup_array; [match_type]
Returns the relative position of an item in an array that matches a specified value

INDEX(array,row_num,[column_num])
Returns a value or reference of the cell at the intersection of a particular row and column, in a given range

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

COUNTIF(range,criteria)
Counts the number of cells within a range that meet a given condition

SMALL(array,k) returns the k-th smallest row number in this data set.

ROW(reference) returns the rownumber of a reference

SUM(number1,[number2],)
Adds all the numbers in a range of cells

### Related posts:

How to sort cells filtered by two dates

Extract and sort text cells from a range containing both numerical and text values

Sort text cells alphabetically from two columns using excel array formula

Sort values in parallel in excel, part 2

Sort cell values into categories, part 2