# How to Sort Multiple Columns in Excel Independently of Each Other (2 Easy Ways)

Get FREE Advanced Excel Exercises with Solutions!

In this article, we will show how to sort multiple columns in Excel independently of each other. In Microsoft Excel, there are a lot of ways to arrange text data alphabetically, dates chronologically, and numbers from smallest to largest or from highest to lowest. Moreover, there are some ways to customize the sorting process. With that Excel 365 offers a brand-new way to sort data with formulas which is very comfortable and astonishingly simple to use.

## How to Sort Multiple Columns in Excel Independently of Each Other (2 Easy Ways)

In this article, we will discuss how to sort multiple columns in Excel independently of each other. Firstly, we will use a VBA code to sort the columns. Then, we will use the SORTBY and LEN functions in each column to resolve the matter. Here, we have a dataset of fruits with their delivery information and quantities. We are going to sort those columns independently.

### 1. Using VBA Code

VBA codes are a very effective way to do a complicated Excel operation with a click of a button. Using VBA code, we can easily sort all the data in multiple columns at once. Letâ€™s see how to do that.

Steps:

• Firstly, go to the Developer tab.
• From there, select the Visual Basic command.
• As a result, the visual basic window will be on the screen.

• From the Visual Basic window, first, select Insert.
• From the available options, choose Module.
• Consequently, a module will be on the screen.

• In the module, write the following code and save it.
``````Sub Sort_multiple_columns()
Dim xRg As Range 'Declare range for Columns
Dim yRg As Range 'Declare range for Rows
Dim Am_ws As Worksheet 'Name the WorkSheet
Set Am_ws = ActiveSheet
On Error Resume Next
Set xRg = Application.InputBox(Prompt:="Range Selection:", _
Title:="Sort Multiple Columns", Type:=8)
Application.ScreenUpdating = False
For Each yRg In xRg
With Am_ws.Sort
.SortFields.Clear
.SetRange Am_ws.Range(yRg, yRg.End(xlDown))
.MatchCase = False
.Apply
End With
Next yRg
Application.ScreenUpdating = True
End Sub
``````

• Again, go to the Developer tab.
• Then, choose Macros.
• As a result, a prompt will be on the screen.

• From the prompt, first, select the code name.
• Then, click on Run.
• As a result, a prompt will be on the screen.

• In the prompt, first, select the B5:F15 range as the desired range.
• Then, click OK.

• Consequently, all the columns will be sorted independently at once.

### 2. Sort Multiple Columns in Excel Independently of Each Other by String Length

The SORTBY function sorts the data in a range based on a criterion. The LEN function returns the length of a text as a numerical value. We can easily sort data by their string length using SORTBY and LEN functions. Now we will sort each column of the previous data by its string length.

Steps:

• Firstly, select the B13 cell and type,
`=SORTBY(B5:B10, LEN(B5:B10),1)`
• Hit the Enter button.
• As a result, the B5:B10 range will be sorted by the text length.

• Secondly, choose the C13 cell and enter,
`=SORTBY(C5:C10, LEN(C5:C10),1)Â `
• Then, press Enter.
• Consequently, the C5:C10 range will be sorted according to lower to greater numbers.

• Thirdly, choose the D13 cell and enter the following formula,
`=SORTBY(D5:D10, LEN(D5:D10),1)`
• Then, press the Enter button.
• Consequently, we will have a sorted D5:D10 range according to earlier to later date.

• After that, select the E13 cell and insert the following formula,
`=SORTBY(E5:E10, LEN(E5:E10), 1)`
• Press Enter.
• Consequently, the E5:E10 range will be sorted.

• Finally, click on the F13 cell and type the formula below,
`=SORTBY(F5:F10, LEN(F5:F10), 1)`
• Then, hit Enter.
• As a result, the column will be sorted by lower to higher price.

Formula Explanation

• LEN(F5:F16) will find the length of the selected rows.
• SORTBY function sorts them according to their length number.

You are welcome to download the practice workbook from the link below.

## Conclusion

In this article, we have talked about how to sort multiple columns in Excel independently of each other. We have shown all the methods with their respective examples but there can be many other iterations. We have also discussed the fundamentals of the used functions. If you have any questions regarding this essay, feel free to let us know in the comments. Also, if you want to see more Excel content like this, please visit our website Exceldemy,Â and unlock a great resource for Excel-related content.

## What is ExcelDemy?

ExcelDemy Learn Excel & Excel Solutions Center provides free Excel tutorials, free support , online Excel training and Excel consultancy services for Excel professionals and businesses. Feel free to contact us with your Excel problems.
Md. Abdullah Al Murad

Hello! Welcome to my Profile. Currently, I am working and researching Microsoft Excel, and here I will be posting articles related to this. My last educational degree is BSc, and my program was Computer Science and Engineering from American International University-Bangladesh. I am a Computer Science graduate with a great interest in research and development. Always try to gather knowledge from various sources and try to make innovative solutions.