Excel built-in data sorting is amazing, but it isn’t dynamic. If you sort data and then add data to it, you would need to sort it again.

#### Sort Data in Alphabetical Order

In this post, I will show you various ways to sort data in alphabetical order using formulas. This means you can add data, and it will automatically sort it for you.

##### When the Data is all Text with No Duplicates

Suppose you have a data as shown below:

In this example, all the data is in text format (no numbers, blanks or duplicates). To sort this, I will use a helper column. In the column next to the data, use the following COUNTIF formula:

`=COUNTIF($A$2:$A$9,"<="&A2)`

This formula compares a text value with all the other text values and returns its relative rank. For example, in cell B2, it returns 8, as there are 8 text values that are lower than or equal to the text ‘US’ (alphabetical order).

Now to sort the values, use the following combination of INDEX, MATCH and ROWS functions:

`=INDEX($A$2:$A$9,MATCH(ROWS($B$2:B2),$B$2:$B$9,0))`

This formula simply extracts the names in the alphabetical order. In the first cell (C2), it looks for the country name that has the lowest number (Australia has 1). In the second cell, it returns Canada (which has the number 2) and so on..

**Allergic to Helper Columns??**

Here is a formula that will do the same without the helper column.

`=INDEX($A$2:$A$9,MATCH(ROWS($A$2:A2),COUNTIF($A$2:$A$9,"<="&$A$2:$A$9),0))`

This is an array formula, so use *Control + Shift + Enter* instead of Enter.

I will leave it for you to de-code.

**Try it Yourself.. Download Example File**

This formula works well if you have text or alphanumeric values.

But it fails miserably if:

- You have duplicates in the data (try putting US twice).
- There are blanks in the data.
- You have a mix of numbers and text (try putting 123 in one of the cells).

##### When Data is a Mix of Numbers, Text, Duplicates, & Blanks

Now this one is a bit tricky. I will use 4 helper columns to show you how it works (and then give you a huge formula that will do it without the helper columns). Suppose you have a data as shown below:

You can see there are duplicate values, blank and numbers. So I will use helper columns to address each of these issues.

**Helper Column 1**

Enter the following COUNTIF formula in Helper Column 1

`=COUNTIF($A$2:$A$9,"<="&A2)`

This formula does the following:

- It returns 0 for blanks.
- In the case of duplicates, it returns the same number.
- Text and numbers are processed parallelly and this formula returns the same number for text and number (for example 123 and India both get 1).

**Helper Column 2 **

Enter the following IS Function in Helper Column 2:

`=--ISNUMBER(A2)`

**Helper Column 3**

Enter the following formula in Helper Column 3:

`=--ISBLANK(A2)`

**Helper Column 4**

Enter the following formula in Helper Column 4

`=IF(ISNUMBER(A2),B2,IF(ISBLANK(A2),B2,B2+$C$10))+$D$10`

The idea for this formula is to segregate blanks, numbers and text values.

- If the cell is blank, it returns the value in cell B2 (which would always be 0) and adds the value in cell D10. In a nutshell, it will return the total number of blank cells in the data
- If the cell is a numerical value, it will return the comparative rank and add the total number of blanks. For example, for 123 it returns 2 (1 is the rank of 123 in the data, and there is 1 blank cell)
- If it is text, it returns the comparative rank and add the total number of numerical values and blanks. For example, for India, it add the text’s comparative rank in text (which is 1) and adds the number of blank cells and the number of numerical values.

**Final Result – Sorted Data**

Now we will use these helper columns to get the sorted list. Here is the formula:

`=IFERROR(INDEX($A$2:$A$9,MATCH(SMALL($E$2:$E$9,ROWS($F$2:F2)+$D$10),$E$2:$E$9,0)),"")`

This method of sorting now becomes fool-proof. I have shown you the method for 8 items, but you can extend it to as many items as you want.

**Try it Yourself.. Download Example File**

**One Formula to Sort it All (without Helper Columns)**

If you can handle extreme formulas, here is an all-in-one formula that will sort data in alphabetical order (without any helper column).

Here is the formula:

`=IFERROR(INDEX($A$2:$A$9,MATCH(SMALL(NOT($A$2:$A$9="")*IF(ISNUMBER($A$2:$A$9),COUNTIF($A$2:$A$9,"<="&$A$2:$A$9),COUNTIF($A$2:$A$9,"<="&$A$2:$A$9)+SUM(--ISNUMBER($A$2:$A$9))),ROWS($A$2:A2)+SUM(--ISBLANK($A$2:$A$9))),NOT($A$2:$A$9="")*IF(ISNUMBER($A$2:$A$9),COUNTIF($A$2:$A$9,"<="&$A$2:$A$9),COUNTIF($A$2:$A$9,"<="&$A$2:$A$9)+SUM(--ISNUMBER($A$2:$A$9))),0)),"")`

Enter this formula in a cell and drag it down to get the sorted list. Also, since this is an array formula, use *Control + Shift + Enter* instead of Enter.

This formula has real world utility. What do you think? I would love to learn from you. Leave your footprints in the comments section!

##### Related Tutorials:

- Multi-level Sorting in Excel.
- Step-by-step Guide to Use Sorting in Excel.
- Concatenate Excel Ranges (with and without separator).