Ever received or generated a spreadsheet of data that would be a lot more useful if it was sorted how you needed it? With previous versions of Excel or if you choose the wrong options in your configuration, it is easy to sort a single column but break the correlation between the data in that column and the rest of the entries in each row. Here’s how to sort the spreadsheet by a single column and get all of your data to move with it. As an example, let’s say here’s your data. For the teachers, the spreadsheet was prepared and sorted by last name. However, for us, that’s not as useful. We think it would be better to be sorted by building. Right now, that data in this small excerpt of the data is a mess. Select all of your data. You can do this by highlighting all of the data or I think it’s better to select all of the columns by clicking and dragging from the first column to the last. Once the data is selected, switch to the Data tab and hit the Sort button. The Sort button will bring up a window where you can configure things with more details. Since my data has the headers of Building, Room Number, and Teacher, I’m going to leave the ‘My data has headers’ box checked. If you don’t have headers and just have data, uncheck the box. Next, go down to the lower level and choose what column you want to sort by. For us, that is ‘Building’. The next to columns allow us to choose what to ‘Sort On’. Since we care about the values in the fields, we’re going to stick with the default ‘Values’. We want it to be alphabetical, so we’ll leave it A to Z. You can then hit the Ok button and the selected data will be sorted as you specified. Now your resulting data is sorted by the column you specified and the rest of the columns remained intact with each row. You can use that Sort window for more complicated sorting by clicking the ‘Add Level’ button. This will allow you to sort by additional columns in case there is a tie in the first specified column.
Notes: Potential Issues
Notes:
Notes: Potential Issue
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.
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.
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.
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.
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:
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.
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.
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.
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.
|