Disclosure: This post may contain affiliate links, meaning when you click the links and make a purchase, we receive a commission.

How to Auto Sort In Excel When Data Is Entered

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 which will be very useful in any excel related task.


Download Practice Workbook

You can download the practice workbook from here.


4 Simple Methods to Auto Sort in Excel When Data Is Entered

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.

auto sort when data is entered in excel


1. Using 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)

sort function to auto-sort in excel when data is entered in ascending order

  • 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.

Read More: How to Sort Data by Value in Excel (5 Easy Methods)


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)

sort function to auto-sort in descending order in excel when data is entered

  • 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.

Read More: How to Sort Alphanumeric Data in Excel (With Easy Steps)


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.


Similar Readings


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.

Read More: Excel VBA to Populate Array with Cell Values (4 Suitable Examples)


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.

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.


Further Readings

Asikul Himel
13 Comments
  1. Reply
    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.

    Kanhaiyalal Newaskar

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

  3. Reply
    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

    • Reply
      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.

Leave a reply

ExcelDemy
Logo