# How to Auto Sort in Excel When Data Is Entered (4 Easy Ways)

Get FREE Advanced Excel Exercises with Solutions!

In this tutorial, I am going to show you 4 simple methods to auto-sort in Excel when data is entered. You can quickly use these methods even in large datasets to sort the values in any particular order. Throughout this tutorial, you will also learn some important Excel tools and functions that will be very useful in any Excel-related task.

We have taken a concise dataset to explain the steps clearly. The dataset has approximately 6 rows and 3 columns. Initially, we are keeping all the cells in General format. For all the datasets, we have 3 unique columns which are Product, Storage (units), and Sorted Data. Although we may vary the number of columns later.

## 1. Using the SORT Function for Ascending Sorting

The SORT function in Excel sorts the values in a range that we supply as input in an ascending or descending order. Let us see how to use this function to auto-sort in Excel when we enter any sort of data.

Steps:

• First, go to cell E5 and insert the following formula:
`=SORT(B5:C10,2,1)`

• Now, press Enter and this will insert the data after sorting them according to the set criteria.
• Here, if you now change the Storage units value in the first table for any product, this will automatically sort it in the second table.

## 2. Sorting in Descending Order

We can also use the SORT function to auto-sort in Excel in descending order when data is entered randomly. Follow the steps below to do this.

Steps:

• To begin with, double-click on cell E5 and enter the below formula:
`=SORT(B5:C10,2,-1)`

• Next, press the Enter key and you should get the data in descending order.
• Now, if you change any value in the main data, it will automatically sort it in the new data.

## 3. Auto Sorting Multiple Columns

If you want to auto-sort multiple columns in Excel when data is entered, then you can follow this method. Below are the detailed steps.

Steps:

• To begin this method, double-click on cell E5 and insert the formula below:
`=SORT(B5:C10,{1,2},{1,1})`

• Next, press the Enter key and consequently, this will sort out the 2 columns of the main data table even if we change any value from it.

Read More: Excel Auto Sort When Data Changes

## 4. Applying VLOOKUP Function

The VLOOKUP function in Excel can look up values vertically in a table. In this method, we will see how to apply this function to auto-sort in Excel when we enter any sort of data.

Steps:

• For this, navigate to cell B5 and insert the formula below:
`=RANK.EQ(D5,\$D\$5:\$D\$10)`

• Then, press Enter which will decide the rank for all of the data values.
• Next, manually write the rankings in the second table in ascending order as in the image below.

• Then, type in this formula in cell G5:
`=VLOOKUP(F5,\$B\$5:\$D\$10,2,FALSE)`

• After that, press the Enter key and then insert the following formula in cell H5:
`=VLOOKUP(F5,\$B\$5:\$D\$10,3,FALSE)`

• Finally, again press Enter and this will arrange the data in descending order.

## Things to Remember

• The SORT function is only available in Microsoft 365.
• The result from this function is a dynamic array so can not change the individual values.
• The first argument of the SORT function has to be a range of cells.
• If no criteria are specified, this function will sort in ascending order by default.
• The SORT function will give a #VALUE error if the sort_index is out of range.

You can download the practice workbook from here.

## Conclusion

I hope that you were able to apply the methods that I showed in this tutorial on how to auto-sort in Excel when data is entered. As you can see, there are quite a few ways to achieve this. So wisely choose the method that suits your situation best. If you get stuck in any of the steps, I recommend going through them a few times to clear up any confusion. Lastly, to learn more Excel techniques, follow our ExcelDemy website. If you have any queries, please let me know in the comments.

## 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.
Asikul Himel

Hi! I am Asikul Islam Himel. Glad you are here. I am a Team Leader of ExcelDemy, running an excellent team of five efficient Excel & VBA Content Developers. Here at ExcelDemy, we give the best sustainable solutions by posting articles related to MS Excel-related problems. I have completed my under graduation degree from Bangladesh University of Engineering and Technology and my program was Naval Architecture and Marine Engineering. I have found passion in data analysis and research-based fields. I am currently working to grow my leadership quality. I have a great interest in project management and critical thinking. In my free time, I love to travel and read books.

Kanhaiyalal Newaskar. Sep 5, 2021 at 11:14 AM

Dear Sir, 5th Sept.2021.

Very clearly and nicely you showed this article. Very easy to understand.
Thanking you for the efforts taken.
Awaiting eagerly to receive such notes and articles in future too.
I remain.

2. Thank you, Asikul, I learned a new trick in Excel today. Just keep filling my Excel tool box.

Eric Charles Baumgardner Oct 28, 2021 at 1:12 AM

How do I insert my own workbook value into the code? I am having issues when I paste new data into the tab as the code no longer works once I do that.

• Dear ERIC CHARLES BAUMGARDNER,
In order to enter your own workbook value into the code, you need to change the ranges inside the code. Check the following screenshot. Thanks!

4. Please I need the cracked version of the Excel 365 version to download. I tried every means to get that version but not able to get from it. Kindly help me with a link to a site that have some some for me to download for my window 10 64bit laptop. Thank you. Your formula is working perfectly.

5. i’m getting a Compile Error.
Saying Syntax error.

• Dear SWAROOP,
A syntax error occurs due to misspelling or missing code. Mostly, due to not specifying the condition and not putting closing brackets. You can check the VBA editor which will help you identify the problems. You can try applying the code in a new worksheet to find your solution.

In addition, if you are applying VBA code with your own workbook data, don’t forget to change the ranges. Check the below screenshot. Thanks!

6. Hi, i found your answer very helpful but I have a small problem here as I have my headers in the first two rows. so inorder to work I need the first 2 rows to stay same and the remaining rows have to autosort using this vba script. Is it possible?

• Hello Swaroop,
can you please share your Excel file and explain the question clearly?
Because we didn’t sort our first two rows in this example also.

7. For option 3 Run a VBA Code to Auto Sort When Data Is entered. I’m not a very Excel expert but I did the steps as mentioned an nothing happened. I think that im missing some steps after pasting the code into the VB and save or run the macro. I close the MVB for apps window and then nothing happens

would you mind to help

Naimul Hasan Arif Nov 10, 2022 at 1:57 PM

I will be glad if I could help you even a little.
The most important think here is to be careful about the code range. Input the range in the code according to your dataset.
For more simplification, you can try the following code where the code runs in range B3:B12 and sorts the values in the Ascending order.

Private Sub AutoSort(ByVal Target As Range)
If Not Intersect(Target, Range(“B:B”)) Is Nothing Then
Range(“B3:B12”).Sort Key1:=Range(“B3”), Order1:=xlAscending, Header:=xlNo
End If
End Sub

I hope it’ll run perfectly.

8. Thank you for the information. I was wondering if it is possible to sort two columns based on the second column without creating a new “table”? I have a list of names and a column that has a countif function. I want to sort by the countif function as it updates.

• Hello DERRELL,
Thank you for your question. I will be glad if I can help you even a little.
First of all, YES, you can sort two columns based on the second column without creating a new table.
If you want to know the process in detail, kindly read through the following article.
https://www.exceldemy.com/sort-data-in-excel-by-value/
I hope this will solve your issue. If you still face problems, please feel free to comment again or send your workbook through e-mail so that our team can check the issue.

Advanced Excel Exercises with Solutions PDF