## Sort text cells alphabetically from two columns using excel array formula

Table of Contents

- Sort text from two columns combined (array formula)
- Sort text from multiple cell ranges combined (user defined function)

**Question: **How do I sort text values in two columns combined?

**Answer:**

**Array formula in cell D2:**

Recommended article:

**Sort a range from A to Z using array formula in excel**

Comments(3) Filed in category: Excel, Sort values

This array formula handles duplicates but not blank cells.

### How to create an array formula

- Select cell D2
- Copy/Paste above formula
- Press and hold Ctrl + Shift
- Press enter once
- Release all keys

**Learn the basics of Excel arrays**

Comments(2) Filed in category: Count values, Excel

### How to copy array formula

- Select cell D2
- Copy (Ctrl + c)
- Select cell range D3:D11
- Paste (Ctrl + v)

**Named ranges**

List1 (A2:A5)

List2 (B2:B6)

What is named ranges?

### How to implement array formula to your workbook

Change named ranges. If your list starts at, for example, F3. Change D1:$D$1 in the above formula to F2:$F$2.

Recommended article

**Unique distinct values from multiple columns using array formula**

Comments(23) Filed in category: Excel, Unique distinct values

### Download excel sample file for this tutorial

sort-from-a-to-z-from-two-columns.xls

(Excel 97-2003 Workbook *.xlsx)

**Functions in this article**

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

**ROWS(**array**)** returns the number of rows in a reference or an array

**MATCH(**lookup_value;lookup_array; [match_type]

Returns the relative position of an item in an array that matches a specified value

**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 the given condition

**ISERROR(**value)

Checks whether a value is an error and returns TRUE or FALSE

This blog article is one out of five articles on the same subject:

Comments(81) Filed in category: Excel, Sort values

**Sorting numbers and text cells also removing blanks using an array formula**

Comments(22) Filed in category: Excel

**Create a drop down list containing only unique distinct alphabetically sorted text values**

Comments(76) Filed in category: Drop down lists, Excel

**Sort a range from A to Z using array formula in excel**

Comments(3) Filed in category: Excel, Sort values

### Sort text from multiple cell ranges combined (user defined function)

This user defined function allows you to enter up to 255 arguments or cell ranges. The udf combines all values from all cell ranges and then sorts them from A to Z. It uses a bubblesort algorithm and I don't recommend using large data sets.

**Array formula in cell F2:F12:**

=SortMultipleRanges(A2:B3,C4:C6,D8:D9)

**VBA Code**

Function SortMultipleRanges(ParamArray rng() As Variant) Dim temp() As Variant 'Count cells For Each cellrange In rng i = i + cellrange.Cells.CountLarge Next cellrange ReDim temp(1 To i, 1 To 1) i = 0 For Each cellrange In rng For Each cell In cellrange i = i + 1 If cell <> "" Then temp(i, 1) = cell Next cell Next cellrange SortMultipleRanges = BubbleSort(temp) End Function

Function BubbleSort(str As Variant) Dim tmp As String, c As Integer, temp As String Dim a As Long, b As Long For a = LBound(str, 1) To UBound(str, 1) For b = a + 1 To UBound(str, 1) If str(a, 1) > str(b, 1) Then tmp = str(a, 1) str(a, 1) = str(b, 1) str(b, 1) = tmp End If Next b Next a BubbleSort = str End Function

### Download excel *.xlsm file

### Category: Sort values

Comments(81) Filed in category: Excel, Sort values

Sort dates within a date range using excel array formula

Question: I have a list of unsorted dates. I want to extract records between two dates and I want the […]Comments(23) Filed in category: Excel, Sort values

Extract unique distinct values from a filtered table (udf and array formula)

Robert Jr asks: Oscar, I am using the VBA code & FilterUniqueSort array to generate unique lists that drive Selection […]Comments(17) Filed in category: Excel, Sort values, Unique distinct values

Sort values in parallel (array formula)

Table of contents How to sort a table by Column 1 and then by Column 2 (array formula) How to […]Comments(16) Filed in category: Excel, Sort values

Lookup and return multiple values sorted in a custom order

Pat asks: Hi Oscar, Thanks for creating such a helpful website and I've a question if I would like to […]Comments(13) Filed in category: Excel, Sort values, Vlookup

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 […]Comments(12) Filed in category: Dates, Excel, Sort values

Comments(7) Filed in category: Excel, Sort values

Comments(7) Filed in category: Excel, Mod, Sort values

Sort values in a cell using a custom delimiter (vba)

The following macro let´s you select a cell range and a delimiting character. The macro sorts the values in each […]Comments(5) Filed in category: Excel, Sort values

### 13 Responses to “Sort text cells alphabetically from two columns using excel array formula”

### Leave a Reply

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

<code>your formula</code>

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

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

VBA code

[/vb]

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

Upload picture to postimage.org

Add picture link to comment.

**Contact Oscar**

You can contact me through this webpage

Hi oscar,

Is possible to make a dropdown list as below?

[IMG]https://i65.photobucket.com/albums/h232/alien3660/dropdown.gif[/IMG]

condition:

1,two column of data

2,remove blank cells

3,only show one time of duplicated data

thank & best rgds,

senen

Senen,

Open attached file:

drop-down-list-from-two-columns-and-no-blanks.xlsx

Hi Oscar,

Thanks for ur reply,can u make it in .xls format b'cos i can't open .xlsx file in my pc...

sry for the inconvenience.

Thank & best rgds,

senen

Senen,

Try this file:

how-to-extract-a-unique-distinct-list-from-two-columns-in-excel-2003.xls

From the code listed, how does sending the sum of multiple COUNTIFs as 2nd parameter to MATCH() supposed to accomplish anything? MATCH() expects an array, not a value, for its 2nd parameter.

Anonymous,

The COUNTIFS functions return arrays in this formula.

Did you provide formula to sort andmerged between 2 or 3 list?

Thanks Oscar, great website, much learn from you....

How about 3 Columns? Merged and Sort them?

Sami

Sami,

I recommend using a custom function:

Merge,sort and remove blanks from multiple cell ranges

Need help :(

I have 10 sheets and all are the same format for each user to work on. column A list the order# which left alot of blank row at the bottom as we need to add more data day by days, all order# are difference for all sheets. and I have a master sheet. I want to combine all the order# which short from the 10 sheets ignore blank. please, avoiding VBA code because I know very little about it.

Thanks and best regard,

Rath

Rath,

Sorry, I don´t know using formulas but my add-in might be helpful:

https://www.get-digital-help.com/2010/02/28/combine-data-from-multiple-sheets-in-excel/#mergeranges

I have a problem how to combine and sort 2 columns with blanks? Is that possible with formula? No UDF or VBA?

thanks in advance

Sami

I made a udf:

https://www.get-digital-help.com/2009/07/01/sort-text-cells-alphabetically-from-two-columns-using-excel-array-formula/#sortudf