Sorting data is an integral part of data analysis. You might want to arrange a list of names in alphabetical order, compile a list of product inventory levels from highest to lowest, or order rows by colors or icons. Sorting data helps you quickly visualize and understand your data better, organize and find the data that you want, and ultimately make more effective decisions.
You can sort data by text (A to Z or Z to A), numbers (smallest to largest or largest to smallest), and dates and times (oldest to newest and newest to oldest) in one or more columns. You can also sort by a custom list you create (such as Large, Medium, and Small) or by format, including cell color, font color, or icon set.
Notes:
-
To find the top or bottom values in a range of cells or table, such as the top 10 grades or the bottom 5 sales amounts, use AutoFilter or conditional formatting.
-
For more information, see Filter data in an Excel table or range, and Apply conditional formatting in Excel .
Sort text
-
Select a cell in the column you want to sort.
-
On the Data tab, in the Sort & Filter group, do one of the following:
-
To quick sort in ascending order, click (Sort A to Z).
-
To quick sort in descending order, click (Sort Z to A).
-
Notes:
Potential Issues
-
Check that all data is stored as text If the column that you want to sort contains numbers stored as numbers and numbers stored as text, you need to format them all as either numbers or text. If you do not apply this format, the numbers stored as numbers are sorted before the numbers stored as text. To format all the selected data as text, Press Ctrl+1 to launch the Format Cells dialog, click the Number tab and then, under Category, click General, Number, or Text.
-
Remove any leading spaces In some cases, data imported from another application might have leading spaces inserted before data. Remove the leading spaces before you sort the data. You can do this manually, or you can use the TRIM function.
-
Select a cell in the column you want to sort.
-
On the Data tab, in the Sort & Filter group, do one of the following:
-
To sort from low to high, click (Sort Smallest to Largest).
-
To sort from high to low, click (Sort Largest to Smallest).
-
Notes:
-
Potential Issue
-
Check that all numbers are stored as numbers If the results are not what you expected, the column might contain numbers stored as text instead of as numbers. For example, negative numbers imported from some accounting systems, or a number entered with a leading apostrophe (‘) are stored as text. For more information, see Fix text-formatted numbers by applying a number format.
-
Select a cell in the column you want to sort.
-
On the Data tab, in the Sort & Filter group, do one of the following:
-
To sort from an earlier to a later date or time, click (Sort Oldest to Newest).
-
To sort from a later to an earlier date or time, click (Sort Newest to Oldest).
-
Notes:
Potential Issue
-
Check that dates and times are stored as dates or times If the results are not what you expected, the column might contain dates or times stored as text instead of as dates or times. For Excel to sort dates and times correctly, all dates and times in a column must be stored as a date or time serial number. If Excel cannot recognize a value as a date or time, the date or time is stored as text. For more information, see Convert dates stored as text to dates.
-
If you want to sort by days of the week, format the cells to show the day of the week. If you want to sort by the day of the week regardless of the date, convert them to text by using the TEXT function. However, the TEXT function returns a text value, so the sort operation would be based on alphanumeric data. For more information, see Show dates as days of the week.
You may want to sort by more than one column or row when you have data that you want to group by the same value in one column or row, and then sort another column or row within that group of equal values. For example, if you have a Department column and an Employee column, you can first sort by Department (to group all the employees in the same department together), and then sort by name (to put the names in alphabetical order within each department). You can sort by up to 64 columns.
Note: For best results, the range of cells that you sort should have column headings.
-
Select any cell in the data range.
-
On the Data tab, in the Sort & Filter group, click Sort.
-
In the Sort dialog box, under Column, in the Sort by box, select the first column that you want to sort.
-
Under Sort On, select the type of sort. Do one of the following:
-
To sort by text, number, or date and time, select Values.
-
To sort by format, select Cell Color, Font Color, or Cell Icon.
-
-
Under Order, select how you want to sort. Do one of the following:
-
For text values, select A to Z or Z to A.
-
For number values, select Smallest to Largest or Largest to Smallest.
-
For date or time values, select Oldest to Newest or Newest to Oldest.
-
To sort based on a custom list, select Custom List.
-
-
To add another column to sort by, click Add Level, and then repeat steps three through five.
-
To copy a column to sort by, select the entry and then click Copy Level.
-
To delete a column to sort by, select the entry and then click Delete Level.
Note: You must keep at least one entry in the list.
-
To change the order in which the columns are sorted, select an entry and then click the Up or Down arrow next to the Options button to change the order.
Entries higher in the list are sorted before entries lower in the list.
If you have manually or conditionally formatted a range of cells or a table column by cell color or font color, you can also sort by these colors. You can also sort by an icon set that you created with conditional formatting.
-
Select a cell in the column you want to sort.
-
On the Data tab, in the Sort & Filter group, click Sort.
-
In the Sort dialog box, under Column, in the Sort by box, select the column that you want to sort.
-
Under Sort On, select Cell Color, Font Color, or Cell Icon.
-
Under Order, click the arrow next to the button and then, depending on the type of format, select a cell color, font color, or cell icon.
-
Next, select how you want to sort. Do one of the following:
-
To move the cell color, font color, or icon to the top or to the left, select On Top for a column sort, and On Left for a row sort.
-
To move the cell color, font color, or icon to the bottom or to the right, select On Bottom for a column sort, and On Right for a row sort.
Note: There is no default cell color, font color, or icon sort order. You must define the order that you want for each sort operation.
-
-
To specify the next cell color, font color, or icon to sort by, click Add Level, and then repeat steps three through five.
Make sure that you select the same column in the Then by box and that you make the same selection under Order.
Keep repeating for each additional cell color, font color, or icon that you want included in the sort.
You can use a custom list to sort in a user-defined order. For example, a column might contain values that you want to sort by, such as High, Medium, and Low. How can you sort so that rows containing High appear first, followed by Medium, and then Low? If you were to sort alphabetically, an “A to Z” sort would put High at the top, but Low would come before Medium. And if you sorted “Z to A,” Medium would appear first, with Low in the middle. Regardless of the order, you always want “Medium” in the middle. By creating your own custom list, you can get around this problem.
-
Optionally, create a custom list:
-
In a range of cells, enter the values that you want to sort by, in the order that you want them, from top to bottom as in this example.
-
Select the range that you just entered. Using the preceding example, select cells A1:A3.
-
Go to File > Options > Advanced > General > Edit Custom Lists, then in the Custom Lists dialog box, click Import, and then click OK twice.
Notes:
-
You can create a custom list based only on a value (text, number, and date or time). You cannot create a custom list based on a format (cell color, font color, or icon).
-
The maximum length for a custom list is 255 characters, and the first character must not begin with a number.
-
-
-
Select a cell in the column you want to sort.
-
On the Data tab, in the Sort & Filter group, click Sort.
-
In the Sort dialog box, under Column, in the Sort by or Then by box, select the column that you want to sort by a custom list.
-
Under Order, select Custom List.
-
In the Custom Lists dialog box, select the list that you want. Using the custom list that you created in the preceding example, click High, Medium, Low.
-
Click OK.
-
On the Data tab, in the Sort & Filter group, click Sort.
-
In the Sort dialog box, click Options.
-
In the Sort Options dialog box, select Case sensitive.
-
Click OK twice.
It’s most common to sort from top to bottom, but you can also sort from left to right.
Note: Tables don’t support left to right sorting. To do so, first convert the table to a range by selecting any cell in the table, and then clicking Table Tools > Convert to range.
-
Select any cell within the range you want to sort.
-
On the Data tab, in the Sort & Filter group, click Sort.
-
In the Sort dialog box, click Options.
-
In the Sort Options dialog box, under Orientation, click Sort left to right, and then click OK.
-
Under Row, in the Sort by box, select the row that you want to sort. This will generally be row 1 if you want to sort by your header row.
Tip: If your header row is text, but you want to order columns by numbers, you can add a new row above your data range and add numbers according to the order you want them.
-
To sort by value, select one of the options from the Order drop-down:
-
For text values, select A to Z or Z to A.
-
For number values, select Smallest to Largest or Largest to Smallest.
-
For date or time values, select Oldest to Newest or Newest to Oldest.
-
-
To sort by cell color, font color, or cell icon, do this:
-
Under Sort On, select Cell Color, Font Color, or Cell Icon.
-
Under Order select a cell color, font color, or cell icon, then select On Left or On Right.
-
Note: When you sort rows that are part of a worksheet outline, Excel sorts the highest-level groups (level 1) so that the detail rows or columns stay together, even if the detail rows or columns are hidden.
To sort by a part of a value in a column, such as a part number code (789-WDG-34), last name (Carol Philips), or first name (Philips, Carol), you first need to split the column into two or more columns so that the value you want to sort by is in its own column. To do this, you can use text functions to separate the parts of the cells or you can use the Convert Text to Columns Wizard. For examples and more information, see Split text into different cells and Split text among columns by using functions.
Warning: It is possible to sort a range within a range, but it is not recommended, because the result disassociates the sorted range from its original data. If you were to sort the following data as shown, the selected employees would be associated with different departments than they were before.
Fortunately, Excel will warn you if it senses you are about to attempt this:
If you did not intend to sort like this, then press the Expand the selection option, otherwise select Continue with the current selection.
If the results are not what you want, click Undo .
Note: You cannot sort this way in a table.
If you get unexpected results when sorting your data, do the following:
Check to see if the values returned by a formula have changed If the data that you have sorted contains one or more formulas, the return values of those formulas might change when the worksheet is recalculated. In this case, make sure that you reapply the sort to get up-to-date results.
Unhide rows and columns before you sort Hidden columns are not moved when you sort columns, and hidden rows are not moved when you sort rows. Before you sort data, it’s a good idea to unhide the hidden columns and rows.
Check the locale setting Sort orders vary by locale setting. Make sure that you have the proper locale setting in Regional Settings or Regional and Language Options in Control Panel on your computer. For information about changing the locale setting, see the Windows help system.
Enter column headings in only one row If you need multiple line labels, wrap the text within the cell.
Turn on or off the heading row It’s usually best to have a heading row when you sort a column to make it easier to understand the meaning of the data. By default, the value in the heading is not included in the sort operation. Occasionally, you may need to turn the heading on or off so that the value in the heading is or is not included in the sort operation. Do one of the following:
-
To exclude the first row of data from the sort because it is a column heading, on the Home tab, in the Editing group, click Sort & Filter, click Custom Sort and then select My data has headers.
-
To include the first row of data in the sort because it is not a column heading, on the Home tab, in the Editing group, click Sort & Filter, click Custom Sort, and then clear My data has headers.
If your data is formatted as an Excel table, then you can quickly sort and filter it with the filter buttons in the header row.
-
If your data isn’t already in a table, then format it as a table. This will automatically add a filter button at the top of each table column.
-
Click the filter button at the top of the column you want to sort on, and pick the sort order you want.
-
To undo a sort, use the Undo button on the Home tab.
-
Pick a cell to sort on:
-
If your data has a header row, pick the one you want to sort on, such as Population.
-
If your data doesn’t have a header row, pick the topmost value you want to sort on, such as 634535.
-
-
On the Data tab, pick one of the sort methods:
-
Sort Ascending to sort A to Z, smallest to largest, or earliest to latest date.
-
Sort Descending to sort Z to A, largest to smallest, or latest to earliest date.
-
Let’s say you have a table with a Department column and an Employee column. You can first sort by Department to group all the employees in the same department together, and then sort by name to put the names in alphabetical order within each department.
Select any cell within your data range.
-
On the Data tab, in the Sort & Filter group, click Custom Sort.
-
In the Custom Sort dialog box, under Column, in the Sort by box, select the first column that you want to sort.
Note: The Sort On menu is disabled because it’s not yet supported. For now, you can change it in the Excel desktop app.
-
Under Order, select how you want to sort:
-
Sort Ascending to sort A to Z, smallest to largest, or earliest to latest date.
-
Sort Descending to sort Z to A, largest to smallest, or latest to earliest date.
-
-
To add another column to sort by, click Add and then repeat steps five and six.
-
To change the order in which the columns are sorted, select an entry and then click the Up or Down arrow next to the Options button.
If you have manually or conditionally formatted a range of cells or a table column by cell color or font color, you can also sort by these colors. You can also sort by an icon set that you created with conditional formatting.
-
Select a cell in the column you want to sort
-
On the Data tab, in the Sort & Filter group, select Custom Sort.
-
In the Custom Sort dialog box under Columns, select the column that you want to sort.
-
Under Sort On, select Cell Color, Font Color or Conditional Formatting Icon.
-
Under Order, select the order you want (what you see depends on the type of format you have). Then select a cell color, font color, or cell icon.
-
Next, you’ll choose how you want to sort by moving the cell color, font color, or icon:
Note: There is no default cell color, font color, or icon sort order. You must define the order that you want for each sort operation.
-
To move to the top or to the left: Select On Top for a column sort, and On Left for a row sort.
-
To move to the bottom or to the right: Select On Bottom for a column sort, and On Right for a row sort.
-
-
To specify the next cell color, font color, or icon to sort by, select Add Level, and then repeat steps 1- 5.
-
Make sure that you the column in the Then by box and the selection under Order are the same.
-
Repeat for each additional cell color, font color, or icon that you want included in the sort.
-
On the Data tab, in the Sort & Filter group, click Custom Sort.
-
In the Custom Sort dialog box, click Options.
-
In the Options menu, select Case sensitive.
-
Click OK.
It’s most common to sort from top to bottom, but you can also sort from left to right.
Note: Tables don’t support left to right sorting. To do so, first convert the table to a range by selecting any cell in the table, and then clicking Table Tools > Convert to range.
-
Select any cell within the range you want to sort.
-
On the Data tab, in the Sort & Filter group, select Custom Sort.
-
In the Custom Sort dialog box, click Options.
-
Under Orientation, click Sort left to right
-
Under Row, in the ‘Sort by’ drop down, select the row that you want to sort. This will generally be row 1 if you want to sort by your header row.
-
To sort by value, select one of the options from the Order drop-down:
-
Sort Ascending to sort A to Z, smallest to largest, or earliest to latest date.
-
Sort Descending to sort Z to A, largest to smallest, or latest to earliest date
-
Need more help?
You can always ask an expert in the Excel Tech Community or get support in the Answers community.
See also
Use the SORT and SORTBY functions to automatically sort your data.
If you select the wrong rows and columns or less than the full cell range that contains the information you want to sort, Microsoft Excel can’t arrange your data the way you want to view it. With a partial range of cells selected, only the selection sorts.
Contents
- 1 Why is Excel not allowing me to sort?
- 2 How do I enable sort in Excel?
- 3 How do I enable sort and filter in Excel?
- 4 Why is sort grayed out in Excel?
- 5 Why is Excel not sorting all columns?
- 6 How do I unlock a filter in Excel?
- 7 How do I sort in Excel without mixing data?
- 8 How do I sort Excel columns separately?
- 9 How do you reset sort in Excel?
- 10 Why is filter greyed out in Excel?
- 11 How do you fix a filter problem in Excel?
- 12 How do I turn off filter mode in Excel?
- 13 Why does my Excel filter not include all rows?
- 14 Why is my excel not sorting largest to smallest?
- 15 How do I sort all sheets in Excel workbook?
- 16 How do I make an Excel spreadsheet alphabetical order?
- 17 How do I sort excel and keep rows together?
- 18 How do you sort columns in sheets without mixing data?
- 19 How do I sort all rows and columns in Excel?
- 20 What is difference between sorting and filtering?
Why is Excel not allowing me to sort?
The most common reason why the Sort and Filter icon is grayed out in Excel is because multiple sheets are selected.To ensure that you have only one active sheet in order to enable Soft and Filter icon, right click on the sheets and click on Ungroup Sheets. The Sort and Filter icon will now become active.
How do I enable sort in Excel?
Sorting levels
- Select a cell in the column you want to sort by.
- Click the Data tab, then select the Sort command.
- The Sort dialog box will appear.
- Click Add Level to add another column to sort by.
- Select the next column you want to sort by, then click OK.
- The worksheet will be sorted according to the selected order.
How do I enable sort and filter in Excel?
Select a cell in the column you want to sort (a column with numbers). Click the Sort & Filter command in the Editing group on the Home tab. Select From Smallest to Largest. Now the information is organized from the smallest to largest amount.
Why is sort grayed out in Excel?
Multiple sheets are selected the most likely reason why the Sort and Filter icon is grayed out. Another reason for the Sort and Filter icon to be disabled is because the Sheet is protected. To protect a sheet, go to Review Tab and click on Unprotect Sheet.
Why is Excel not sorting all columns?
Make sure that the headings are only present in the first column. Select the complete table region only. Home tab -> Format Table As -> Choose any of the options and check the heading available when prompted. Try sorting it either ways and it should work for all columns.
How do I unlock a filter in Excel?
You can also press Ctrl+Shift+F or Ctrl+1. In the Format Cells popup, in the Protection tab, uncheck the Locked box and then click OK. This unlocks all the cells on the worksheet when you protect the worksheet.
How do I sort in Excel without mixing data?
Select a cell or range of cells in the column which needs to be sorted. Click on the Data tab available in Menu Bar, and perform a quick sort by choosing any one of the options under the Sort & Filter group, depending upon whether you want to sort in ascending or descending order.
How do I sort Excel columns separately?
If you want to sort the table columns independently from each other, click on the Arrange All button in the ribbon toolbar tab Variables. After clicking, the Arrange_All function appears in the sidebar.
How do you reset sort in Excel?
Here are the steps to create the index column:
- Type a 1 in a blank column to the right of the data range/table.
- Double-click the fill handle to fill the number down.
- Select Series from the Auto Fill Options menu to create a sequential list of numbers 1,2,3,…
Why is filter greyed out in Excel?
A more obscure reason is that the spreadsheet is in sharing mode. When this is true then for some reason the filter by color is not useable. To check if you workbook is shared you can go to the REVIEW tab and click on the SHARE WORKBOOK button.Untick it to switch it off and the filter by colour should reappear.
How do you fix a filter problem in Excel?
On the Home tab, in the Editing group, click Sort & Filter, and then click Clear to clear the filter. Some data in this workbook is filtered by a cell color. Rows that are hidden by the filter will remain hidden, but the filter itself will not display correctly in earlier versions of Excel.
How do I turn off filter mode in Excel?
If you want to completely remove filters, go to the Data tab and click the Filter button, or use the keyboard shortcut Alt+D+F+F.
Why does my Excel filter not include all rows?
Unmerge any merged cells or so that each row and column has it’s own individual content. If your column headings are merged, when you filter you may not be able to select items from one of the merged columns. If you have merged rows, filtering will not pick up all of the merged rows.
Why is my excel not sorting largest to smallest?
Excel number sort order problems
The reason this happens is because Excel has decided that the ‘numbers’ are actually text and so it is sorting the ‘text‘. So in much the same way that words sort based on there letters, the numbers sort on the digits instead of the value.
How do I sort all sheets in Excel workbook?
Follow these steps:
- Select the worksheets you want to sort.
- Click on “Sort Sheets” on the Professor Excel ribbon.
- Fine-tune the options. For example sort all worksheets or just the selected worksheets. Or group them by tab color. Press “Start”.
How do I make an Excel spreadsheet alphabetical order?
How to alphabetize columns in Excel
- Find the “Data” tab at the top of your spreadsheet.
- You can sort data by any column.
- Select how you’d like to alphabetize.
- Your data will be reorganized by column.
- Click “Options…”
- Switch to alphabetizing from left to right.
- Provide instructions to order data by row.
How do I sort excel and keep rows together?
2. In the Sort Warning window, select Expand the selection, and click Sort. Along with Column G, the rest of the columns will also be sorted, so all rows are kept together. This technique works for any sort, including sorting by date or sorting alphabetically.
How do you sort columns in sheets without mixing data?
Click Data and select Sort range from the drop-down menu. The Sorting dialog box appears. Select the desired column you want to sort by. Select ascending or descending.
How do I sort all rows and columns in Excel?
You can use these steps to sort multiple rows or columns in Excel:
- Highlight the data items you want to sort.
- Open the Data menu from the top of the program.
- Enter the sorting window.
- Add another column or row to the sorting window.
- Choose “Custom Sort” in the sorting window.
- Confirm by hitting “OK”
What is difference between sorting and filtering?
Essentially, sorting and filtering are tools that let you organize your data. When you sort data, you are putting it in order. Filtering data lets you hide unimportant data and focus only on the data you’re interested in.
Last Update: Jan 03, 2023
This is a question our experts keep getting from time to time. Now, we have got the complete detailed explanation and answer for everyone, who is interested!
Asked by: Bridgette Crona
Score: 4.2/5
(63 votes)
If you select the wrong rows and columns or less than the full cell range that contains the information you want to sort, Microsoft Excel can’t arrange your data the way you want to view it. With a partial range of cells selected, only the selection sorts. With empty cells selected, nothing happens.
How do I enable column sorting in Excel?
Sorting levels
- Select a cell in the column you want to sort by. …
- Click the Data tab, then select the Sort command.
- The Sort dialog box will appear. …
- Click Add Level to add another column to sort by.
- Select the next column you want to sort by, then click OK. …
- The worksheet will be sorted according to the selected order.
Why is sort and filter not working in Excel?
Another reason why your Excel filter may not be working may be due to merged cells. Unmerge any merged cells or so that each row and column has it’s own individual content. If your column headings are merged, when you filter you may not be able to select items from one of the merged columns.
How do I fix sorting problems in Excel?
Problems with Sorting Excel Data
- Select one cell in the column you want to sort.
- Press Ctrl + A, to select the entire region.
- Check the selected area, to make sure that all the data is included. …
- If all the data was not selected, fix any blank columns or rows, and try again.
Why won’t my numbers sort in Excel?
Excel number sort order problems
The reason this happens is because Excel has decided that the ‘numbers’ are actually text and so it is sorting the ‘text’. … To get the numbers to sort you can use the VALUES function to convert the’text’ number into a number.
32 related questions found
Why does Excel not sort all columns?
Make sure that the headings are only present in the first column. Select the complete table region only. Home tab -> Format Table As -> Choose any of the options and check the heading available when prompted. Try sorting it either ways and it should work for all columns.
Why won’t my dates sort in Excel?
Custom Format for using . is not recognised by Excel, hence that could be the reason it could not sort. Make sure you have no blank rows between the heading (e.g. «date») and the date values in the column below the heading. These rows may be hidden, so be sure to unhide them and delete them.
How do you reset sort in Excel?
Go to the Data ribbon and click the Clear icon in the Sort & Filter group. Go to the Home ribbon, click the arrow below the Sort & Filter icon in the Editing group and choose Clear.
Can’t sort merged cells Excel?
General solution
- Select the entire range you want to sort.
- In the Alignment group on the Home tab, select the Alignment dialog box launcher.
- Select the Alignment tab, and then clear the Merge cells check box.
- Select OK.
How do I make column headings in Excel?
Add a Header Row
If your data is already present in the top row, right-click on the number «1» on the top of the left side of the spreadsheet and choose «Insert» from the pop-up menu to create a new top row, then enter your headings by typing in the appropriate cell.
Where is advanced sort in Excel?
To find these options, click the Data tab and then click the Sort option in the Sort & Filter group. Then, click the Options button to launch the dialog shown in Figure A. (You must select a range of values to access these settings.) Display Excel’s advanced sorting options.
What is sorting in Excel?
Sorting in Excel is arranging data according to our requirements. It can be done alphabetically or numerically. Basic Sorting works when sorting is to do on only one column. Advanced Sorting is used in multi-level sorting, viz sorting required in 2 or more than 2 columns.
How do you sort columns in Excel without mixing data?
General Sort
- Click into any cell in the COLUMN you want to sort by within your list. (DO NOT highlight that column as this will sort that column only and leave the rest of your data where it is.)
- Click on the DATA tab.
- Click on either the Sort Ascending or Sort Descending. button.
How do you make all cells the same size to sort?
Merged Cells Need To Be the Same Size
- Use Ctrl +A (Cmd + A on Mac) to highlight the whole range and then click the Unmerge cells button/link.
- If you can’t find the «unmerge cells» button you can go to View/Toolbars/Customize and then search for it on the «Commands» tab under the «Format» category.
How do you sort data in Excel?
Sort by more than one column or row
- Select any cell in the data range.
- On the Data tab, in the Sort & Filter group, click Sort.
- In the Sort dialog box, under Column, in the Sort by box, select the first column that you want to sort.
- Under Sort On, select the type of sort. …
- Under Order, select how you want to sort.
Which is not a function in MS Excel?
The correct answer to the question “Which one is not a function in MS Excel” is option (b). AVG. There is no function in Excel like AVG, at the time of writing, but if you mean Average, then the syntax for it is also AVERAGE and not AVG.
Can you save a custom sort in Excel?
Normally we can save filter criteria by Custom Views feature in Excel, but the Custom Views feature can’t reserve custom sort criteria/order.
How do I enable sort and filter in Excel?
Click any cell in the range or table. On the HOME tab, click Sort & Filter, and click Filter. Click a drop-down arrow at the top of one of the columns to display its filter options. I click the drop-down arrow in the Category column.
Why is Excel changing my dates to numbers?
Microsoft Excel is preprogrammed to make it easier to enter dates. … If you only have a few numbers to enter, you can stop Excel from changing them into dates by entering: A space before you enter a number. The space remains in the cell after you press Enter.
How do I force Excel to format date?
Follow these steps:
- Select the cells you want to format.
- Press CTRL+1.
- In the Format Cells box, click the Number tab.
- In the Category list, click Date.
- Under Type, pick a date format. …
- If you want to use a date format according to how another language displays dates, choose the language in Locale (location).
How do you sort dates in Excel by month and day?
How to sort by date in Excel
- In your spreadsheet, select the dates without the column header.
- On the Home tab, click Sort & Filter and choose Sort Oldest to Newest.
- The Sort Warning dialog box will appear. Leave the default Expand the selection option selected, and click Sort:
Do hidden columns get sorted in Excel?
You should know that if your worksheet contains hidden rows, they are not affected when you sort by rows. If you have hidden columns, they are not affected when you sort by columns. After the sort, they will remain in the same position as before the sort.
Can formula be sorted in Excel?
Excel SORT function — automatically sort with formula. … You will learn a formula to sort alphabetically in Excel, arrange numbers in ascending or descending order, sort by multiple columns, and more.
Can you lock sorting in Excel?
Click “Protect Sheet…” Give the worksheet a password. Uncheck the worksheet protection property called “Select Locked Cells” Check the “Sort” property and the “AutoFilter” properties.
How do you sort excel by column and keep rows together?
To do this, use Excel’s Freeze Panes function. If you want to freeze just one row, one column or both, click the View tab, then Freeze Panes. Click either Freeze First Column or Freeze First Row to freeze the appropriate section of your data.
I have a very basic worksheet with multiple columns and rows. I usually will sort one column to sort a-z and normally all data for those rows would follow the sort. Suddenly I am finding that if I sort one column, the remaining columns do not sort, even though I choose the «Expand The Selection». I have also noticed that after sorting, the worksheet is split into one set of columns on the left side that did sort, another set of columns on the right did not follow the sort. It is split. I have about 45 columns and 150 rows so the worksheet is particularly large.
Completely befuddled.
asked Dec 20, 2015 at 16:31
3
This happens when all the column is not a part of one table, even though it is within one sheet.
- Ctrl + A
- Clear all filters or sorting. Home tab -> Sort & Filter -> Clear
- Make sure that the headings are only present in the first column.
- Select the complete table region only.
- Home tab -> Format Table As -> Choose any of the options and check the heading available when prompted.
- Try sorting it either ways and it should work for all columns.
answered Jul 2, 2018 at 14:04
I have found in some circumstances that the table simply needs to be resized.
Follow these steps and see if they help:
1) click anywhere within your table
2) click Design
3) at the far left of the ribbon, click Resize Table
4) fix the data range so that the entire table is within the range, i.e. if the range says, C1:E114, and the A and B columns through row 114 should be included in range, adjust the range to A1:E114.
Hope this helps when all else fails.
answered Sep 24, 2018 at 8:52
Excel automatically tries to find your total data range, and it stumbles over blank fields. So if your cursor is in a line where there a blank fields in some columns, Excel could miss the columns behind the blanks fields (and similar for blank rows). This is still true when you chose ‘extend’.
One solution is to 1. use Autofilters, that will make Excel remember what is in your range; another is to 2. put the cursor in a field where there are no blank fields in the row (and column); a third way is to 3. select the whole range yourself; and of course, the problem goes away if you 4. don’t have blank cells anywhere.
I recommend the Autofilter solution if it doesn’t bother you otherwise, as it makes sure that you don’t accidentally sort some day a part only because you forgot to do 2. or 3.
answered Dec 21, 2015 at 2:24
AganjuAganju
9,8843 gold badges21 silver badges40 bronze badges
In my case it was because I had empty hidden columns between the content columns and for some reason Excel was considering them as some sort of separator. For example if I clicked Ctrl + A
while having a cell selected, it would only select the columns between the nearest empty columns.
In order to fix this, remove the empty columns.
answered Jun 13, 2017 at 20:03
If you selected yourself the range of cells, and it does not sort properly, you may have created tables within what you consider your table. To find out:
- Go right above the first line, on the top left, where the cell number appears (
F16
,M34
, whatever) - Select the arrow going down.
- Case a) nothing appears, it is all blank, then just try the solutions in the other comments
- Case b) some stuff appears. If so, these are tables, you need to get rid of them (it does not delete your cells)
To get rid of the tables:
- Click on each of the lines that appeared (the ones that appeared in case b). Basically, when you click on one, a bunch of cells are highlighted.
- Right click on any of the highlighted cells (basically you are right clicking on the whole range anyway)
- Go to table and delete the table (if «table» is not part of the menu when you right click, you did not have any table created)
- Repeat these steps for all of the tables (i.e., for each line that appeared when you clicked on the drop down menu next to the cell name)
You can now happily sort your data.
answered Dec 18, 2017 at 3:59
SamiaSamia
11 bronze badge
Does your data have filters? If so, select header row with filters, then remove all filters (right click, Filter, clear filter). Then select header row again, and add filters back. After doing so I was able to sort my data and all columns sorted. Hope this helps!
answered Jun 20, 2018 at 14:00
You most probably added new columns after filtering former columns, so new column headers «have NOT filter signs». Excel exclude these columns when you filter.
So, clear filtering by clicking on Sort$Fliter>Filter, then add the filter sign to «all» columns again by hitting the Filter button again. There you go!
answered Jun 11, 2022 at 16:44
I have a solution.
U have to have Sort column next to your data and it will do the right thing.
Hope will help u.
answered Jan 5, 2017 at 22:45
1
Excel puts blanks at the bottom when you sort.
- Ctrl-G (Go to)
- Click Special
- Check Blanks, click OK
All blanks will now be selected. Select a background color to change all blank cells.
Now you can sort by color and have blanks appear at the top.
answered Feb 14, 2017 at 19:43
1
Microsoft Excel sheet information plays a crucial role when you slice it and dice it in small sections to put the meaningful data. But the problem occurs when you frequently cannot sort all the columns accurately. You’re just disappointed and seeking help from any expert or searching on Google on how to fix and why my excel not sorting all the columns.
Relax, this kind of problem is very natural since most of them are easy to fix. Microsoft Excel combines some columns and rows to arrange and set up the data according to the user command. All the data here is arranged through a straight command. Putting any wrong command or selecting a full cell range without making a selection can be why the Excel sheet is not sorted.
Along with these, some more affairs influence this difficult matter to happen. Let’s learn and solve them unitedly.
Microsoft Excel data sheet cannot perform or display the way you expected to some crucial issues. The reason behind this depends on the user experience and data-driving knowledge excellence. Some common reasons are that your excel is not sorting all columns for the wrong selection, wrong or mixed data type, file or application corruption, etc.
As you can see, those exigent causes that always interrupt occur for the user’s mistake and unconsciousness. Below I add them, so you can take an idea for fixing the problem yourself.
Wrong Selection Of Rows & Columns
Selecting the wrong rows and columns on the Excel sheet is a common mistake many users make. Again, if any user chooses a full cell range less than the column size, the sheet can’t arrange the data that you wanted to create in it. It may show you only selection sorts when you choose a partial range of cells.
Again, a user may not be able to create or sort anything in it when the cell is empty. You should open the sort dialog box and the selection area first. Then enclose those data to organize your data properly.
You’ve Already Sorted Data In Excel
Another reason that strung you to arrange all data fruitfully is to switch on to pre-arranged data. Sometimes Microsoft Excel shows sorting issues if any user enters the already sorted data. Pre-arranged data always remains invisible, and users have trouble sorting all Excel columns.
To make Excel appear to have responded to your command, in that case, undo all sorting. But, so that you’ve already organized your data in it, Excel can’t sort the same data twice into the same order. Now, ask what to do then. To fix this problem, you need to alter the sort parameters.
Wrong / Mixed Data Types
Wrong or mixed data types are often responsible for this sort of problem. Without accurate information, your Excel couldn’t interpret them and also failed to give exact output. For example, you have mistakenly set up a lot of data and text on the Excel sheet.
And finally, notice that your data won’t sort properly. This could happen due to mixing that cell format because you have mixed up lots of raw or column altogether ignorantly, which ended up with a lot of jumble. Your Excel sorting problem also happened and depended on how you displayed your data. You’re giving commands, and input can influence how you interpret the results during the data sorting operation.
Besides this, sometimes your Excel sheet shows the date of previous years or the month didn’t match the present. Check your data and cell types whenever you notice this odd result.
File / Application Corruption
File or application corruption can also be crucial in incorrectly sorting all Excel columns. This problem can happen to unexpected results in routine software operations such as worksheet data sort. To resolve sorting problems, keep shutting down Microsoft Excel and restart the computer. Check the sheet once again to see if the problem is solved.
Alternatively, copy the whole worksheet contents and paste them into the new Excel file. Give some trial of your sort operation there. If this solves your problem, quit here; meanwhile, if it is not solved, read out the possible fixes below.
How to Avoid Excel not Sorting All Columns?
Precautions are better than regrets. In this sense, you can avoid trouble decorating an Excel worksheet properly by learning some tricks. Below I have discussed how anyone can avoid painful mistakes when sorting spreadsheets in multiple columns, rows, or custom orders.
Backup Your Data
Keep trying to back up all your data from Excel every day. It is a fundamental way to avoid such inconvenience. Before sorting any data from the sheet, make a backup copy. Afterward, go back to the saved version if anything seems wrong. Meanwhile, you can easily back up the copy using the free Excel Backup tool.
This tool helps you to back up all the current folders that don’t affect the active workbook. Since it is a format backup tool, anyone can easily install them on their computer.
Remove Blank Rows Or Column
Your second step is to remove blank rows or columns from Excel. Make this as if it’s your regular habit before making any new data sheet on it. Refresh all the old data, so the software can free from empty, blank rows or columns. Maybe now you’re looking for a way to do this? No worries, follow these steps as per my instructions.
- Open your computer, and go to Excel. Select any of the cells from there that you want to sort.
- Keep your finger on the keyboard and press “Ctrl+A” to select the entire cell region.
- Now, check out the selected area thoroughly to ensure that all the data is included.
Solve Blanks Rows & Columns Issues
After detecting the blank rows and columns, your next step is to fix them. Some common issues like this may bother you. For example, you’ll see a hidden column where E is blank. Or, after pressing the key “Ctrl+A ”, you see that columns F, G, H, and I have completely vanished. Watch out for them carefully before removing all blank rows or columns. Now, practice the below indications to fix the problem.
- If some data is not selected, or you skip it, find the blank row or column.
- Then, unhide each row or column from the sheet to find the blank ones.
- Once you find them, look closely at them. If any of them isn’t necessary for you, then delete them.
- Enter all the items you want to keep in the rows or columns. Then, press “Ctrl+A” once again.
- Finally, check whether the entire rows or columns are selected or filled by the region.
- If they’re not selected, then delete them. Afterward, safely sorted the data, which was selected by the entire region perfectly.
How to Sort Excel Columns?
From now on, you will get an idea about how to fix the Excel sorting issues and learn how to avoid them. But in this section, I want to share some quick tips to sort the Excel column by using both (A-Z) ascending order and (Z-A) descending order on the Ribbons Data tab.
1. Quick Sort Using Sort Buttons
Use the sort buttons and see the results within a second. To do this follows these steps properly:
- Open the Excel sheet, and select any cells you want to sort.
- From the Excel Ribbon, click on the Data tab.
- Select “Sort A to Z” for smallest to largest / “Sort Z to A” for largest to smallest.
- After doing this, quickly check the sorted data to see if those (columns & rows) are sorted correctly or not.
- Keep the sorted data that seems perfect. Then, undo the unsorted data from there.
2. Sort Buttons on Quick Access Toolbar
The quick Access toolbar is a magic wand for those who sort frequently. Add this quick access button toolbar to make it easier to sort your data immediately. Here’s a complete guide to having this tool on your computer Excel data sheet.
- From the pivot table, select a cell, then click on the Excel Ribbon. Click on the design tab.
- Tap on both Arrow on the Report layout button and the options.
From Pivot Table to Tabular Layout:
- Select a cell from the pivot table
- Next, click on the “Show in Tabular Form” command
- After selecting this, you’ll see an option on “Add to Quick Access Toolbar.”
You can also add this tool by the shortcut option of “Close All.” Once you’re done, sort your Excel columns at any time without any trouble.
3. Sort Two or More Columns
Use this shortcut when it seems necessary to sort 2 or more columns. Before that, make sure to use the Sort dialog box. It will help you to set up multi-level sorting. For sorting 2 to 3 or more columns, a user can do the following 3 initial basics.
- First, sorting by gender.
- Then, by state
- Finally, using the Birth Year.
Step 1: Sorting Process for 3 Columns
- Open Microsoft Excel, and select all the cells.
- Find out the Excel Ribbon, and click on the Data tab.
- From there, you need to select the Sort & Filter group, then tap on the Sort button.
- Select the Add Level button and then add your first sorting level.
- Afterward, there you also get an option “Sort by dropdown.” Click it further to select the first column which you want to sort.
In case, the dropdown shows you Column letters instead of headings. You can sort the columns through “My data” as a header.
- From the Sort on the dropdown, select all the options you want. There you’ll get four initial options. Select any of them, such as clicking on “Values” if you’re sorting Gender columns.
- Now, from the order dropdown, select one of the options. This time, the order dropdown option varies because it depends on the norms of selection which you want to sort on. Since I give an example of values, you might get order options like A to Z, Z to A, and Custom list. That’s why I selected A to Z.
Step 3: Click On “Add Level Buttons”
Hence, there you are, sorting multiple columns. Just do these last steps to achieve the final output.
- Click on “Add level button” > then add to “next level.”
- Now, select the options from the dropdown boxes.
Here, I’ve selected Gender, state, and Birth year as the sort field for showing you as an example. Then sorted them all as values. It’s because the Birth Year here contains only numbers. This is why its order options are slightly different from the text column.
Step 4: Click On “OK” for Selecting All The Sort Levels
After selecting all sorts of levels, click on “OK.” You’ll then see a gender column sorted at the top of the section first. Then, the state column is sorted by birthday year and city at the top of each.
Final Words
After finishing this, I assure you that you’ll never face a problem and will be able to fix issues like excel not sorting all columns or not displaying the way you expected. Those issues are normal, so most of them can be solved alone.
However, before ending this conversation, I also want to add a few tips. If the above method is not working, try re-sorting the column and verifying them once again. You can reset the sorting filter in Excel also for fixing this. Click on the home tab, then edit the group. Click Sort and filter, then finish it by tapping on Clear.
Sorting data in Excel has been made quite easy with all the in-built options.
You can easily sort your data alphabetically, based on the value in the cells, or by cell and font color.
You can also do multi-level column sorting (i.e., sorting by column A and then by column B) as well as sorting rows (from left to right).
And if that was not enough, Excel also allows you to create your own custom lists and sort based on that too (how cool is that). So you can sort data based on shirt sizes (XL, L, M, S) or responses (strongly agree, agree, disagree) or intensity (high, medium, low)
Bottom line – there are just too many sorting options you have at your disposal when working with Excel.
And in this massive in-depth tutorial, I will show you all these sorting options and some cool examples where these can be useful.
Since this a huge tutorial with many topics, I am providing a table of content below. You can click on any of the topics and it will instantly take you there.
Accessing the Sorting Options in Excel
Since sorting is such a common thing needed when working with data, Excel provides a number of ways for you to access the sorting options.
Sorting Buttons in the Ribbon
The fastest way to access sorting options is by using the sorting buttons in the ribbons.
When you click on the Data tab in the ribbon, you will see the ‘Sort & Filter’ options. The three buttons on the left in this group is for sorting the data.
The two small buttons allow you to sort your data as soon as you click on these.
For example, if you have a data set of names, you can just select the entire dataset and click on any of the two buttons to sort the data. The A to Z button sorts the data alphabetically lowest to highest and the Z to A button sorts the data alphabetically highest to lowest.
This buttons also work with numbers, dates or times.
Personally, I never use these buttons as these are limited in what these can do, and there are more chances of errors when using these. But in case you need a quick sort (where there are no blank cells in the dataset), these can be a fast way to do it.
Sorting Dialog Box
In the Data tab in the ribbon, there is another Sort button icon within the sorting group.
When you click this Sort button icon, it opens the sorting dialog box (something as shown below).
Sorting dialog is the most complete solution for sorting in Excel. All the sorting related options can be accessed through this dialog box.
All the other methods of using sorting options are limited and don’t offer full functionality.
This is the reason I always prefer using the dialog box when I have to sort in Excel.
A major reason for my preference is that there is very less chance of you going wrong when using the dialog box. Everything is well structured and marked (unlike buttons in the ribbon where you may get confused which one to use).
In this tutorial, you’ll find me mostly using the dialog box to sort the data. This is also because some of the things I cover in certain sections (such as multi-level sorting or sorting from left-to-right) can only be done using the dialog box.
Keyboard Shortcut – If you need to sort data often in Excel, I recommend you learn the keyboard shortcut to open the sort dialog box. It’s ALT + A + S + S
Sorting Options in the Filter Menu
If you have applied filters to your dataset, you can also find the sorting options along with the filter options. A filter can be applied by selecting any cell in the dataset, clicking on the Data tab and clicking in the Filter icon.
Suppose you have a dataset as shown below and you have the filter applied.
When you click on the filter icon for any column (it’s the small downward pointing triangle icon at the right of the column header cell), you’ll see some of the sorting options there as well.
Note that these sorting options change based on the data in the column. So if you have text, it will show you the option to sort from A to Z or Z to A, but if you have numbers, it will show you options to sort from largest to smallest or smallest to largest.
Right-click options
Apart from using the dialog box, using right-click is another method that I sometimes use (it’s also super fast as it only takes two clicks).
When you have a dataset that you want to sort, right-click on any cell and it will show you the sorting options.
Note that you see some options that you don’t see in the ribbon or in the Filter options. While there is the usual sort by value and custom sort option (which opens the Sort dialog box), you can also see options such as Put selected Cell color/Font color/Formatting icon on the top.
I find this option quite useful as it allows me to quickly get all the colored cells (or cells with a different font color) together at the top. I often have the monthly expense data that I go through and highlight some cells manually. I can then use this option to quickly get all these cells together at the top.
Now that I have covered all the ways to access sorting options in Excel, let’s see how to use these to sort data in different scenarios.
Also read: How to Undo Sort in Excel (Revert to Original)
Sorting Data in Excel (Text, Numbers, Dates)
Caveat: Most of the times, sorting works even when you select a single cell in the dataset. But in some cases, you may end up with issues (when you have blank cells/rows/columns in your dataset). When sorting data, it’s best to select the entire data set and then sort it – just to avoid any chance of issues.
Based on the type of data you have, you can use the sorting options in Excel.
Sorting by Text
Suppose you have a dataset as shown below and you want to sort all these records based on the name of the student in alphabetical order.
Below are the steps to sort this text data in alphabetical order:
- Select the entire dataset
- Click the Data tab
- Click the Sort icon. This will open the Sort dialog box.
- In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
- In the ‘Sort by’ drop-down, select ‘Name’
- In the ‘Sort On’ drop-down, make sure ‘Cell Values’ is selected
- In the Order drop-down, select A-Z
- Click OK.
The above steps would sort the entire dataset and give the result as shown below.
Why not just use the buttons in the ribbon?
The above method of sorting data in Excel may look like a lot of steps, as compared to just clicking the sort icon in the ribbon.
And this is true.
The above method is longer, but there is no chance of any error.
When you use the sort buttons in the ribbon, there are a few things that can go wrong (and this could be hard to spot when you have a large data set.
While I discuss the drawbacks of using the buttons later in this tutorial, let me quickly show you what can go wrong.
In the below example, since Excel cannot recognize that there is a header row, it sorts the entire dataset, including the header.
This issue is avoided with the sort dialog box as it explicitly gives you the option to specify whether your data has headers or not.
Since using the Sort dialog box eliminates chances of errors, I recommend you use it instead of all the other sorting methods in Excel
Sorting by Numbers
Now, I am assuming you have already gotten a hang of how text sorting works (covered above this section).
The other types of sorting (such as based on numbers or dates or color) is going to use almost the same steps with minor variations.
Suppose you have a dataset as shown below and you want to sort this data based on the marks scored by each student.
Below are the steps to sort this data based on numbers:
- Select the entire dataset
- Click the Data tab
- Click the Sort icon. This will open the Sort dialog box.
- In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
- In the ‘Sort by’ drop-down, select ‘Name’
- In the ‘Sort On’ drop-down, make sure ‘Cell Values’ is selected
- In the Order drop-down, select ‘Largest to Smallest’
- Click OK.
The above steps would sort the entire dataset and give the result as shown below.
Sorting by Date/Time
While the date and time may look different, they are nothing but numbers.
For example, in Excel, the number 44196 would be the date value for 31 December 2020. You can format this number to look like a date, but in the backend in Excel, it still remains a number.
This also allows you to treat dates as numbers. So you can add 10 to a cell with date, and it will give you the number for the date 10 days later.
And the same goes for the time in Excel.
For example, the number 44196.125 represents 3 AM on 31st December 2020. While the integer part of the number represents a full day, the decimal part would give you the time.
And since both date and time are numbers, you can sort these like numbers.
Suppose you have a dataset as shown below and you want to sort this data based on the project submission date.
Below are the steps to sort this data based on the dates:
- Select the entire dataset
- Click the Data tab
- Click the Sort icon. This will open the Sort dialog box.
- In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
- In the ‘Sort by’ drop-down, select ‘Submission Date’
- In the ‘Sort On’ drop-down, make sure ‘Cell Values’ is selected
- In the Order drop-down, select ‘Oldest to Newest’
- Click OK.
The above steps would sort the entire dataset and give the result as shown below.
Note that while date and time are numbers, Excel still recognized that these are different in the way it’s displayed. So when you sort by date, it shows ‘Oldest to Newest’ and ‘Newest to Oldest’ sorting criteria, but when you use numbers, it shows ‘Largest to Smallest’ or ‘Smallest to Largest’. Such small things that makes Excel an awesome spreadsheet tool (PS: Google Sheets doesn’t show so much detail, just the bland sort by A-Z or Z-A)
Sorting by Cell Color / Font Color
This option is amazing and I use it all the time (maybe a tad bit too much).
I often have data sets that I analyze manually and highlight cells while I am doing it. For example, I was going through a list of articles on this blog (which I have in an Excel sheet) and I highlighted the ones which I needed to improve.
And once I am done, I can quickly sort this data based on the cell colors. This helps me in getting all these highlighted cells/rows together at the top.
And to add to the awesomeness, you can sort based on multiple colors. So if I highlight cells with article names which need immediate attention in red and some which can be dealt with later with yellow, I can sort the data to show all the red rows first followed by the yellow.
If you’re interested in learning more, I recently wrote this article on sorting based on multiple colors. In this section, I will quickly show you how to sort based on one color only
Suppose you have a dataset as shown below and you want to sort by color and get all the red cells at the top.
Below are the steps to sort by color:
- Select the entire dataset
- Click the Data tab
- Click the Sort icon. This will open the Sort dialog box.
- In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
- In the ‘Sort by’ drop-down, select ‘Submission Date’ (or whatever column where you have the colored cells).Since in this example we have colored cells in all the columns, you can choose any.
- In the ‘Sort On’ drop-down, select ‘Cell Color’.
- In the Order drop-down, select the color with which you want to sort. In case you have multiple cell colors in the dataset, it will show you all those colors here
- In the last drop-down, select ‘On Top’. This is where you specify whether you want the colored cells to be on the top of the dataset or at the bottom.
- Click OK.
The above steps would sort your dataset by color and you will get the result as shown below.
Just as we have sorted this data based on the cell color, you can also do it based on the font color and conditional formatting icon.
Multiple Level Data Sorting
In reality, datasets are rarely as simple as the one that I am using in this tutorial.
Yours may extend to thousands of rows and hundreds of columns.
And when you have datasets so big, there is also a need for more data slice and dice. Multiple level data sorting is one of the things you may need when you have a large data set.
Multiple level data sorting means that you can sort the dataset based on values in one column and then sort it again based on values in another column(s).
For example, suppose you have the dataset as shown below and you want to sort this data based on two criteria:
- The region
- The sales
The output of this sorting based on the above two criteria will give you a dataset as shown below.
In the above example, we have the data first sorted by the regions and then within each region, the data is further sorted by the sales value.
This quickly allows us to see which sales reps are doing great in each region or which ones are doing poorly.
Below are the steps to sort the data based on multiple columns:
- Select the entire data set that you want to sort.
- Click the Data tab.
- Click on the Sort Icon (the one shown below). This will open the Sort dialog box.
- In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
- In the Sort Dialogue box, make the following selections
- Sort by (Column): Region (this is the first level of sorting)
- Sort On: Cell Values
- Order: A to Z
- Click on Add Level (this will add another level of sorting options).
- In the second level of sorting, make the following selections:
- Then by (Column): Sales
- Sort On: Values
- Order: Largest to Smallest
- Click OK
Pro Tip: The Sort dialog box has a feature to ‘Copy Level’. This quickly copies the selected sorting level and then you can easily modify it. It’s good to know feature and may end up saving you time in case you have to sort based on multiple columns.
Below is a video where I show how to do a multi-level sorting in Excel:
Sorting Based on a Custom List
While Excel already has some common sorting criteria (such as sorting alphabetically with text, smallest to largest or largest to smallest with numbers, oldest to newest or newest to oldest with dates), it may not be enough.
To give you an example, suppose I have the following dataset:
Now, if I sort it based on the region alphabetically, I have two options – A to Z or Z to A. Below is what I get when I sort this data alphabetically from A to Z using the region column.
But what if I want this sort order to be East, West, North, South?
You, of course, can rearrange the data after sorting, but that’s not the efficient way to do this.
The right way to do this would be using custom lists.
A custom list is a list that Excel allows you to create and then use just like the inbuilt lists (such as month names or weekday names). Once you have created a custom list, you can use it in features such as data sorting or fill handle.
Some example where custom lists can be useful include:
- Sorting the data based on region/city name
- Sorting based on T-shirt sizes – Small, Medium, Large, Extra Large
- Sorting based on survey responses – Strongly Agree, Agree, Neutral, Disagree
- Sorting based on probability – high, medium, low
The first step in trying to sort based on the custom criteria is to create the custom list.
Steps to create a custom list in Excel:
- Click the File tab
- Click on Options
- In the Excel Options Dialogue Box, select ‘Advanced’ from the list in the left pane.
- Within Advanced selected, scroll down and select ‘Edit Custom List’.
- In the Custom Lists dialogue box, type your criteria in the box titled List Entries. Type your criteria separated by comma (East, West, North, South) [you can also import your criteria if you have it listed].
- Click Add
- Click OK
Once you have completed the above steps, Excel will create and store a custom list that you can use for sorting data.
Note that the order of the items in the custom list is what determines how your list will be sorted.
When you create a custom list in one Excel workbook, it becomes available to all the workbooks in your system. So you only have to create it once and can reuse it in al workbooks.
Steps to sort using a custom list
Suppose you have the dataset as shown below and you want to sort it based on the regions (the sort order being East, West, North, and South)
Since we have already created a custom list, we can use it to sort our data.
Here are the steps to sort a dataset using a custom list:
- Select the entire dataset
- Click the Data tab
- Click the Sort icon. This will open the Sort dialog box.
- In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
- In the ‘Sort by’ drop-down, select ‘Region’ (or whatever column where you have the colored cells)
- In the ‘Sort On’ drop-down, select ‘Cell Values’.
- In the Order drop-down, select ‘Custom List’. As soon as you click on it, it will open the Custom Lists dialog box.
- In the Custom Lists dialog box, select the custom list you have already created from the left pane.
- Click OK. Once you do this, you will see the custom sort criteria in the sort order drop-down field
- Click OK.
The above steps will sort your dataset based on the custom sort criteria.
Note: You don’t have to create a custom list before-hand to sort the data based on it. You can also create it while you’re in the Sort dialog box. When you click on Custom List (in step 7 above), it opens the custom list dialog box. You can create a custom list there as well.
Custom lists are not case sensitive. In case you want to do a case-sensitive sorting, refer to this example.
Also read: How to Sort by Length in Excel? Easy Formulas!
Sorting from Left to Right
While in most cases you’ll likely sort based on the column values, sometimes, you may also have a need to sort based on the row values.
For example, in the below dataset, I want to sort it based on the values in the Region row.
Although this type of data structure is not as common as the columnar data, I have still seen a lot of people working with this kind of construct.
Excel has an in-built functionality that allows you to sort from left to right.
Below are the steps to sort this data from left to right:
- Select the entire dataset (except the headers)
- Click the Data tab
- Click the Sort icon. This will open the Sort dialog box.
- In the Sort dialog box, click on Options.
- In the Sort Options dialog box, select ‘Sort left to right’
- Click OK.
- In the ‘Sort By’ drop-down, select Row 1. By doing this, we are specifying that the sort needs to be done based on the values in Row 1
- In the ‘Sort On’ drop-down, select ‘Cell Values’.
- In the Order drop-down, select A-Z (you can also use custom sort list if you want)
- Click OK.
The above steps would sort the data left to right based on Row 1 values.
Excel doesn’t recognize (or even allow you to specify) the headers when sorting from left to right. So you need to make sure your header cells are not selected when sorting the data. If you select headers cells as well, these will be sorted based on the value in it.
Note: Another way of sorting the data from right to left could be to transpose the data and get it in a columnar form. Once you have it, you can use any of the sorting methods covered so far. Once the sorting is done, you can then copy the resulting data and paste it as transposed data.
Below is a video where I show how to sort data from left to right in Excel
Case Sensitive Sorting in Excel
So far, in all the example above, the sorting has been case independent.
But what if you want to make the sorting case-sensitive.
Thankfully, Excel allows you to specify whether you want the sorting to be case-sensitive or not.
Note: While most of the times you don’t need to worry about case-sensitive sorting, this may be helpful when you get your data from a database such as Salesforce or you manually collate the data and have different people enter the same text in different cases. Having a case sensitive sort may help you keep all the records by the same person/database together.
Suppose you have a dataset as shown below and you want to sort this data based on the region column:
Below are the steps to sort data alphabetically as well as make it case sensitive:
- Select the entire dataset
- Click the Data tab
- Click the Sort icon. This will open the Sort dialog box.
- In the Sort dialog box, make sure my data has headers is selected. In case your data doesn’t have headers, you can uncheck this.
- Click the Options button
- In the Sort Options dialog box, check the ‘Case sensitive’ option
- Click OK.
- In the ‘Sort by’ drop-down, select ‘Region’
- In the ‘Sort On’ drop-down, select ‘Cell Values’.
- In the order drop-down, select A to Z
- Click OK.
The above steps would not only sort the data alphabetically based on the region, but also make it case-sensitive.
You’ll get the resulting data as shown below:
When you sort from A to Z, lower case text is placed above the upper case text.
Getting the Original Sort Order
Often when sorting data in Excel, you may want to go back to the earlier or the original sort order and start afresh,
While you can use the undo functionality in Excel (using Control Z) to go back one step at a time, it may be confusing if you have already done multiple things after sorting the data.
Also, undo works only till you have the workbook open, but when you save and close and it and open it later, you won’t be able to go back to the original sort order.
Here are two simple ways to make sure you don’t lose the original sort order and get it back even after sorting the data:
- Make a copy of the original dataset. This is something I recommend you do even if you don’t need the original sort order. You can have a workbook with all the data and then simply create a copy of the workbook and work on the copy. When I am working on critical datasets, I make a copy every day (with the date or version number as a part of the workbook name).
- Add a column with a series of number. This series of numbers get all mixed up when you sort the data, but in case you want to go back to the original data, you can sort based in this series of numbers.
In this section, let me quickly show you what mean by adding a series and using it to get original sort order back.
Suppose you have a dataset as shown below:
To make sure you have a way to get back this data after sorting it, add a helper column and have a series of numbers in it (as shown below).
Here is a tutorial with different ways to add a column with numbers quickly
When you have the helper column in place, make sure you include it while sorting this dataset.
Suppose I sort this data based on the region and end up getting the data as shown below:
Now, if I want to go back to the original dataset, I can simply sort this data again, but based on the helper column (from low to high).
Simple.. isn’t it?
In case you don’t want the helper column to show, you can either hide it or create a backup and then delete it.
Some Common Issues While Sorting Data in Excel
At the beginning of this article, I showed you different ways to sort data in Excel (including sort buttons in the ribbon, right-click options, filter option, and the sort dialog box).
And to reiterate, using the sort dialog box minimizes the chances or any issues or error that may arise.
Now, let me show you what can go wrong when you use the sort button from the ribbon (the ones shown below)
Not Identifying the Column Headers
Suppose you have a dataset as shown below:
This looks like a decently formatted data set with headers clearly formatted with cell color and bold font.
So when you sort this data based on the names (using the sort buttons in the ribbon), you would expect the header to remain at the top and rest of the data to get sorted.
But what happens when you do it – the header is also considered as normal data and gets sorted (as shown below).
While Excel is smart enough to recognize headers, in this example, it failed to do so. When using the sort icon buttons in the ribbon, there was no way for you to manually specify that this data has headers.
Note: This issue occurs when I have the dataset and I add and format the headers and sort it. Normally, Excel would be smart enough to identify that there are headers in a dataset (especially when the data type of the header and the data in the column is different). But in this case, it failed to do so when I added the header and sorted right away. If I save this workbook, close it and reopen it, Excel somehow manages to identify the first row and header.
While this may not be an issue in most cases, there is still a chance when you use the sort icons in the ribbon, Using a dialog box eliminates this issue as you can specify that you have headers.
Not Identifying Blank Rows/Columns
This sorting issue is a little more complex – and a lot more common than you would imagine.
Suppose you have a dataset as shown below. Note that row number 6 is hidden (and it’s a blank row).
Now, if I select any cell in the first four rows of the data (the ones above the hidden blank row) and sort this data using the sort icon buttons, it would only sort the first four records on the data set (row 2 to 5). Similarly, if I select any cell in the dataset below the hidden blank row, it will only sort the last seven rows.
And unless you’re looking for it specifically, you’re likely to miss this horrible error.
How to make sure you don’t end up making this sorting error?
To make sure you don’t fall prey to this issue, you need to check your dataset before sorting it.
Select the entire dataset before sorting the data.
You can do that by selecting any cell in the dataset and then using the keyboard shortcut – Control + A.
If there are blank rows/columns in your dataset, the entire dataset won’t get selected. You can identify this by quickly scanning the outline of the selection.
If you see that there is some data left outside the selection, you can manually select it.
To make sure this issue is avoided, it’s best to first unhide all hidden rows and columns and then proceed to sort the data by selecting the entire data set or by first deleting the blank rows.
Partial Sorting (Based on the Last Name)
Sometimes, you may have a dataset that you want to sort based on part of the text.
For example, suppose I have the dataset as shown below and I want to sort this data based on the last name.
To do this, I need to separate this data so that I have only the last names in one column. When I have it, I can use that column to sort the data.
Below is a formula that can give me the last name:
=RIGHT(B2,LEN(B2)-FIND(" ",B2))
This will give you a result as shown below.
Now you can use the Last Name column to sort this data.
Once done, you can delete the last name column or hide it.
Note that the above formula works when you have names that has first and last name only and have no double spaces in between. In case you have names data that is different, you will have to adjust the formula. You can also use Text to Column to quickly split the names based on space character as the delimiter.
This is just one example of sorting based on partial data. Other examples may include sorting based on cities in an address or employee ID based on department codes.
Also, in case the text based on which you need to sort is at the beginning of the text, you can use the normal sort feature only.
Other Sorting Examples (Using Formula and VBA)
So far in this tutorial, I have covered the examples where we have used the in-built sorting functionality in Excel.
Automatically Sorting Using a Formula
When you use the in-built sort functionality and then make any change in the data set, you need to sort it again. The sort functionality is not dynamic.
In case you want to get a dataset that sorts automatically whenever there is any change, you can use the formulas to do it.
Note that to do this, you need to keep the original dataset and the sorted dataset separate (as shown below)
I have a detailed tutorial where I cover how to sort alphabetically using formulas. It shows two methods to do this – using helper columns and using an array formula.
Excel has also introduced the SORT dynamic array formula which can easily do this (without helper column or a complicated array formula). But since this is quite new, you may not have access to it in your version of Excel.
Sorting Using VBA
And finally, if you want to bypass all the sorting dialog box or other sorting options, you can use VBA to sort your data.
In the below example, I have a dataset that sorts the data when I double click on the column header. This makes it easy to sort and can be used in dashboards to make it more user-friendly.
Here is a detailed tutorial where I cover how to sort data using VBA and create something as shown above.
I have tried to cover a lot of examples to show you different ways you can sort data in Excel and all the things you need to keep in mind when doing it.
Hope you found this tutorial useful.
You May Also Like the following Excel Tutorials:
- Search and Highlight Data Using Conditional Formatting
- How to Sort Worksheets in Excel using VBA
- How to Create a Data Entry Form in Excel
- How to Compare Two Columns in Excel
- Excel TRIM Function to Remove Spaces and Clean Data
- Flip Data in Excel | Reverse Order of Data in Column/Row
- How to Shuffle a List of Items/Names in Excel? 2 Easy Formulas!
Sort Column in Excel (Table of Contents)
- Sort Column in Excel
- How to Sort a Column in Excel?
Introduction to Sort Column in Excel
To sort the column in excel, first, select the cell in the column we want to sort and then click on the Sort option, which is available in the Data tab. In the drop-down of Sort By, we will be able to see all the headers name. Select the one which we want to sort. And then select the criteria from Sort On and Values by which we can to sort to the values from that column. We also insert multiple levels by which we can get a more precise or exact output.
How to Sort Column in Excel?
In excel, we can find the SORT under the DATA menu, as shown in the below screenshot.
You can download this Column Sort Excel Template here – Column Sort Excel Template
Where we can find the sort option like A to Z (Ascending to Descending order ) and Z to A (Descending to Ascending Order).
Sort Column in Excel is very simple and easy to use. Let us understand the working of Column Sort in Excel by some examples.
Example #1
In this example, we are going to see how to use the sort function by using the sales data available in the database, as shown below.
The above example has sales data that contain SKU, Product name, BRAND and MRP; now consider that we are going to sort the sales data by A to Z using the Product name as follows:
- First, select column B, a column named product name & apply the sorting.
- Go to the Data menu.
- Choose the A to Z Sorting as shown below.
- Once we click on the A to Z option, we will get the below dialogue box as follows.
- Sorting will ask for two options like either to
- Expand the selection or
- Continue with the current selection.
- Choose the first option to Expand the selection and Click Sort.
- The result will be displayed as A to Z order.
Example #2
In these examples, we will try to sort out the sales data in a reverse order, i.e. Using Z to A Sorting.
Consider the same sales data and apply it to sort by following the below-mentioned procedure as follows.
- First, select the column B column named product name & apply the sorting.
- Go to the Data menu.
- Choose the Z to A Sorting as shown below:
- Sorting will ask for two options like either to
- Expand the selection or
- Continue with the current selection.
- Choose the first option to Expand the selection And Click Sort.
- The result will be displayed as a Z to A order.
- We will get the sales data arranged in Z to A format, as shown below.
Example #3 – Advance Sort Option
In this example, we are going to see the advanced sort option, which allows us to sort out multiple options; so that we can get the specific data that we are looking for; we can find custom sort under sort opting as explained below.
In excel, we can find this custom sort option at the right corner of the ribbon, as shown below:
- Choose the custom sort option where we will get the sorting dialogue box as follows.
- The sorting option will ask to expand the selection or to continue with the current selection.
- Choose the first option to Expand the selection And Click sort.
- We will get the custom sort option dialogue box with multiple sorting, as shown below.
We can see that in the above screenshot has three multiple sorting options as Sort by “Product Title”, By “Values”, and By Order “ A to Z or Z to A.
Now we will see how to use this three different option by following the below procedure:
- Click the Product title.
- It will list the name displayed as follows, which comes from the database header sales data.
- Now we can sort by using multiples title, values and order.
- Consider that we need to sort the sales data by Brand wise with A to Z sorting order.
- Click on the brand option and select the order by A to Z.
- The sorting option will sort out the result by brand wise from A to Z order, as shown below.
We can see that in the above example, that brand column has been sorted by brand-wise with A to Z order.
Example #4
In this example, we will see how to sort the sales data by using numbers.
Let’s consider the sales data, which has selling price for different products as follows. So if we want to find out the least selling price of the product in huge sales data, it’s very difficult to find out the exact least selling prices. In this scenario, we can use the Sorting feature by using numbers to ascend to descending order and vice versa. Let’s see the example with sales data with sorting the numbers.
Here we can see the sales database, which has the product name, Brand-name, MRP, and Selling prices now; let’s see how to sort the numbers from smallest to highest.
- Select the E column cell named SP to sort out the Smallest to Highest numbers.
- Go to the sort option as follows.
- Once we click the sort option, we can see the sorting options like smallest to highest and highest to smallest.
- Select smallest to highest to get the least selling price.
- Now we can see the difference in the selling price that it has been sorted from smallest to highest numbers.
- Same like this, we can do vice versa to get the highest selling price to the lowest selling price by using the sorting opting “Largest to Smallest.
Example #5
In this, we will see how to get the highest selling MRP for a specific product by using sorting.
Let’s consider the below example which has MRP for all the product as shown below:
Here we need to find out which product is selling in Higher MRP. In these cases, we can use the sort option for a number by sorting the largest to smallest as follows:
- Choose the MRP cell and go to the sorting option.
- Choose Sorting option Largest to Smallest.
- The sales data will be rearranged as follows.
Now we can see the sales data very clearly that the MRP column has been sorted from largest to smallest. Now we can configure easily that the above products are selling at the highest MRP.
Things to Remember about Sort Column in Excel
- Don no use a blank column while using sorting in Excel.
- Do not hide the column in Excel while using sorting because once the column is hidden, it cannot be moved while using sorting. So it’s better to unhide the column before applying to sort.
- Enter the caption header in one row and do not merge the cell while sorting a column in excel.
Recommended Articles
This has been a guide to Sort Column in Excel. Here we discuss how to Sort Column in Excel along with practical examples and a downloadable excel template. You can also go through our other suggested articles –
- Excel Sort by Date
- Excel Sort By Number
- Sorting in Excel
- Excel Sort by color