## How to sort text cells filtered by two dates, part 2

*Article last updated on July 19, 2017*

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.

I will use Excel´s countif function in this article.

**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

Download excel sample file for this tutorial

sort-text-cells-between-two-dates

(Excel 97-2003 Workbook *.xls)

**Functions in this article:**

**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

5 easy ways to VLOOKUP and return multiple values

This post explains how to lookup a value and return multiple values. No array formula required.

Lookup and return multiple values concatenated into one cell

This article demonstrates how to find a value in a column and concatenate corresponding values on the same row. The […]

Question: How do I create a chart that dynamically adds the values, as i type them on the worksheet? Answer: […]

### Leave a Reply

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Use the img tag, like this: <img src="Insert pic link here">

**Contact Oscar**

You can contact me through this contact form