How to Sort Columns in Excel Without Mixing Data (6 Handy Ways)

How often do you need to sort in Excel? The generic answer is, “Every now and then”. Sorting is one of the most common tasks while dealing with data. To help you sort correctly, today we are going to show you how to sort columns in Excel without mixing data.


Download Practice Workbook

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


6 Ways to Sort Columns in Excel Without Mixing Data

First things first, let’s get to know about today’s practice workbook.

Marksheet of some students

We have a basic table that contains the name of students and their respective scores in three courses. Using this relationship table, we will see how to sort columns without mixing data.
Note that this is a basic set of dummy data to create a simple scenario, in real cases you may encounter a much larger and more complex data set.
Now, Excel provides you the option to sort the data using its built-in tool. You can easily sort your data using the tools.

  • Select the range or column you want to sort.
  • Here we have selected the Student Name column. We intend to sort the name by A to Z.
  • After selecting the column, explore the Data tab. You will find the Sort & Filter option there. You will find several options there. Select as per your need.

sorting data in excel by one column where data is getting mixed

  • Here our choice was A to Z.
  • Our data has been sorted, see the image below.

data before sorting and mixed data after sorting

Oh, dear! Though we have found the name sorted, the scores are not sorted. The scores are improper for each student now.

So what can we do now? Keep reading this article to explore the solutions.


1. Selecting All Necessary Columns Before Sorting

Let’s roll back to the initial stage of our data. Now follow the steps below.

📌 Steps:

  • Select all the data you want to count within your sort.

Here we have selected all the columns except Serial No. The serial should remain as it is.

  • Then select the Sort option from the Data tab.

Selecting All Necessary Columns Before Sorting to Prevent Data Mixing

  • A dialog box will come in front of you. You can choose your sort preference there.

selecting sort options

  • Make sure to check the My data has headers. 
  • We have selected 4 columns here, so we can sort by either of them.
  • Drop down, you will see the header options. Select what you want.
  • Here we have selected the Student Name column. Our sort was on the Cell Values and the order was A to Z. 
  • You can change these by clicking the drop-down icon of the respective selection.

Now our data has been sorted. We found the name alphabetically and the corresponding scores are also intact.


2. Using ‘Expand the Selection’ Option

Do you know good things about Excel? Yes, there are many, but right now our consideration is all about sorting.

The good thing for sort in Excel is that it will give you a warning before triggering the sort.

📌 Steps:

  • Select any of the columns. Then explore the Sort & Filter section from the Data tab.
  • Here we have selected the Student Name column. And to sort it alphabetically we are going to click A to Z.
  • Once you don’t select the entire table while sorting, Excel will pop up a warning.
  • Here we have two options. If you explicitly need to continue with the selected column (s) then select Continue with the current selection. This option will only filter the selected cells.
  • Usually, you need to use the Expand the selection, this option will count all the columns in your table.

  • Here we are using Expand the selection.
  • Press the Sort option.

Here the name has been sorted alphabetically. And all the other values have also changed their places.


3. Converting to Table

We can convert a normal data range to a table and then apply sorting on this. This will help to sort columns without mixing data. See the steps below.

📌 Steps:

  • At first, select the cells in the B4:F14 range.
  • Then, press the CTRL key followed by the T on your keyboard.

converting to table

Immediately, the Create Table dialog box appears.

  • Secondly, click OK.

As a result, the normal data range is converted into a table.

  • Thirdly, select cells in the Student column.
  • Then, go to the Data tab.
  • Now, click on Sort A to Z.

sing Table command in Excel Sort Columns Without Mixing Data

You can see that the whole dataset became sorted along with this column.


4. Creating a Custom Sort List to Prevent Mixing Data

You can sort the data by your own choice. Excel has the feature of the custom sort to help you with that.

Here we have changed our data a little to show you examples.

We have added a new column that contains the month when students appeared for their respective exams.

As we said earlier, we don’t want to change the serial number (since it’s already in a sequence), we are selecting other columns apart from that.

📌 Steps:

  • Select the Sort from the Sort & Filter. 

  • A Dialog box will come in front of you.

Creating a Custom Sort List to Prevent Mixing Data in Excel while sorting columns

  • From Order click the drop-down icon, and you will see an option there called Custom List. Click that.
  • A new Custom lists dialog box will appear.
  • For your convenience, Excel listed a couple of lists there. Here we have selected the months from there. You can choose depending on your needs.
  • Our selected column was Exam Schedule and the order was by months from January to December. You can set your custom list there.

Now our data has been sorted with the column Exam Schedule by globally sequential months.


5. Using SORT Function in Excel

If you are using Excel 365, then you can use a function called SORT. 

The SORT function sorts the contents of a range or array in ascending or descending order.

Syntax of SORT Function:

SORT (array, [sort_index], [sort_order], [by_col])

  • array: The range, or array to sort
  • sort_index: A number indicating the row or column to sort by. This is an optional field. The default value is 1.
  • sort_order: A number indicating the desired sort order. 1 = Ascending, -1 = Descending. This is also an optional field. The default value is 1 (ascending).
  • by_col: A logical value indicating the desired sort direction. TRUE = sort by column. FALSE = sort by row. The default is FALSE.

📌 Steps:

  • Make use of this function in Excel. The used formula is as follows.
=SORT(C5:F14,1)

Using SORT Function in Excel to sort column without mixing data

  • Here we have entered all the values from the Student Name column to the History column. This was our range. We have several columns within our range, as we wanted to sort by name, which was our 1st column in the range, we inserted 1 as sort_index. 

Read more: How to Sort by Last Name in Excel

  • We can skip this since the default value is 1 for that field. Our Data has been sorted with alphabetically ordered names.

  • For ascending order we can insert 1 in the sort_order field as well (you can see in the above image). Then the formula will be:
=SORT(C5:F14,1,1)
  • For any reason, if you need to sort in descending order use -1 instead of 1 in the sort_order field.
=SORT(C5:F14,1,-1)

Here we have used -1 as sort_order and the names have been sorted from Z to A.


6. Sort Columns Without Mixing Data Using SORTBY Function in Excel

You can use the SORTBY function to sort your data. This is a family function of the previously discussed SORT function.

The SORTBY function sorts the contents of a range or array based on the values from another range or array.

Syntax of SORTBY Function:

SORTBY (array, by_array, [sort_order], [array/order], …)

  • array: Range or array to sort
  • by_array: Range or array to sort by
  • sort_order: The order to use for sorting. 1 for ascending, -1 for descending. Default is ascending
  • array/order: Additional array and sort order pairs.

The latter two are optional.

📌 Steps:

  • To apply this formula, write the following formula in the desired cell:
=SORTBY(C5:F14,C5:C14)

Sort Columns Without Mixing Data Using SORTBY Function in Excel

  • Similar to the previous, we have selected the array. Our by_array was the Student Name column.
  • Can you relate SORT and SORTBY? In SORT we have provided the column number, which was from our selected array, here in SORTBY we have provided the column differently (as an array).
  • SORTBY allows you to sort depending on any outside column or range.
  • Let’s change the by_array.
=SORTBY(C5:F14,D5:D14)

Sort Columns Without Mixing Data Using SORTBY Function in Excel

  • Here we have selected the Math column as our by_array. The Math column had been sorted in ascending order. All the other column values have been changed places respectively.

Conclusion

That’s all for today. We have listed several ways to sort columns in Excel without mixing data. Hope you will find this helpful. Feel free to comment if anything seems difficult to understand. Let us know which of the methods you are going to use. You can also notify us of any of the approaches we might have missed here.


Further Readings

Shakil Ahmed

Shakil Ahmed

My name’s Shakil. My articles are targeted to support you in enriching knowledge regarding different features related to Microsoft Excel. I am fond of literature, hope some knowledge from them will help me providing you some engaging articles even though some weary technical terms.

2 Comments
  1. I was told that if you format the data as a table, then you can reorganise a column A-Z and the remaining data in the additional columns will follow. Is this correct? You don’t mention that method here

    • Hello REBECCA,
      Thanks for your feedback. We are very glad to feel that our readers study our articles attentively. I am very sorry that method was not added. Now, I’m showing the way step by step for your convenience.
      • At first, select the cells in the B4:F14 range.
      • Then, press the CTRL key followed by the T on your keyboard.

      Immediately, the Create Table dialog box appears.
      • Secondly, click OK.

      As a result, the normal data range is converted into a table.

      • Thirdly, select cells in the Student column.
      • Then, go to the Data tab.
      • Now, click on Sort A to Z.

      You can see that the whole dataset became sorted along with this column.

      That’s all from me on this topic. Again, many thanks to you for your subtle observations. I’ll inform it to our editorial team to fix it. We always hope for such positive comments. Follow our website, ExcelDemy, a one stop Excel solution provider, to explore more.
      Regards,
      Shahriar Abrar
      Excel & VBA Content Developer
      Exceldemy

Leave a reply

ExcelDemy
Logo