Sort data in a range or table (2024)

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.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.Check out the video to see how it's done.

WindowsWeb

  1. Select a cell in the column you want to sort.

  2. On the Data tab, in the Sort & Filter group, do one of the following:

    • To quick sort in ascending order, click Sort data in a range or table (1) (Sort A to Z).

    • To quick sort in descending order, click Sort data in a range or table (2) (Sort Z to A).

Notes: Potential Issues

  • Check that all data is stored as textIf 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 spacesIn 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.

  1. Select a cell in the column you want to sort.

  2. On the Data tab, in the Sort & Filter group, do one of the following:

    • To sort from low to high, click Sort data in a range or table (3) (Sort Smallest to Largest).

    • To sort from high to low, click Sort data in a range or table (4) (Sort Largest to Smallest).

Notes:

  • Potential Issue

  • Check that all numbers are stored as numbersIf 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.

  1. Select a cell in the column you want to sort.

  2. 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 data in a range or table (5) (Sort Oldest to Newest).

    • To sort from a later to an earlier date or time, click Sort data in a range or table (6) (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.

  1. Select any cell in the data range.

    Sort data in a range or table (7)

  2. On the Data tab, in the Sort & Filter group, click Sort.

    Sort data in a range or table (8)

  3. In the Sort dialog box, under Column, in the Sort by box, select the first column that you want to sort.

    Sort data in a range or table (9)

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

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

  6. To add another column to sort by, click Add Level, and then repeat steps three through five.

    Sort data in a range or table (10)

  7. To copy a column to sort by, select the entry and then click Copy Level.

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

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

  1. Select a cell in the column you want to sort.

  2. On the Data tab, in the Sort & Filter group, click Sort.

    Sort data in a range or table (11)

  3. In the Sort dialog box, under Column, in the Sort by box, select the column that you want to sort.

    Sort data in a range or table (12)

  4. Under Sort On, select Cell Color, Font Color, or Cell Icon.

    Sort data in a range or table (13)

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

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

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

  1. Optionally, create a custom list:

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

      Sort data in a range or table (14)

    2. Select the range that you just entered. Using the preceding example, select cells A1:A3.

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

  2. Select a cell in the column you want to sort.

  3. On the Data tab, in the Sort & Filter group, click Sort.

    Sort data in a range or table (15)

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

  5. Under Order, select Custom List.

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

  7. Click OK.

  1. On the Data tab, in the Sort & Filter group, click Sort.

    Sort data in a range or table (16)

  2. In the Sort dialog box, click Options.

    Sort data in a range or table (17)

  3. In the Sort Options dialog box, select Case sensitive.

    Sort data in a range or table (18)

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

  1. Select any cell within the range you want to sort.

  2. On the Data tab, in the Sort & Filter group, click Sort.

    Sort data in a range or table (19)

  3. In the Sort dialog box, click Options.

    Sort data in a range or table (20)

  4. In the Sort Options dialog box, under Orientation, click Sort left to right, and then click OK.

    Sort data in a range or table (21)

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

    Sort data in a range or table (22)

    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.

  6. To sort by value, select one of the options from the Order drop-down:

    1. For text values, select A to Z or Z to A.

    2. For number values, select Smallest to Largest or Largest to Smallest.

    3. For date or time values, select Oldest to Newest or Newest to Oldest.

  7. To sort by cell color, font color, or cell icon, do this:

    1. Under Sort On, select Cell Color, Font Color, or Cell Icon.

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

Sort data in a range or table (23)

Fortunately, Excel will warn you if it senses you are about to attempt this:

Sort data in a range or table (24)

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 Sort data in a range or table (25).

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 changedIf 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 sortHidden 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 settingSort 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 rowIf you need multiple line labels, wrap the text within the cell.

Turn on or off the heading rowIt'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.

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

  2. Click the filter button at the top of the column you want to sort on, and pick the sort order you want.

    Sort data in a range or table (26)

  3. To undo a sort, use the Undo button on the Home tab.

    Sort data in a range or table (27)

  1. Pick a cell to sort on:

    • If your data has a header row, pick the one you want to sort on, such as Population.

      Sort data in a range or table (28)

    • If your data doesn’t have a header row, pick the topmost value you want to sort on, such as 634535.

      Sort data in a range or table (29)

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

Sort data in a range or table (30)

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.

  1. On theData tab, in theSort & Filtergroup, click Custom Sort.

    Sort data in a range or table (31)

  2. In the Custom Sort dialog box, underColumn, in theSort by box, select the first column that you want to sort.

    Sort data in a range or table (32)

    Note:The Sort On menu is disabled because it's not yet supported. For now, you can change it in the Excel desktop app.

  3. UnderOrder, 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.

  4. To add another column to sort by, click Add and then repeat steps five and six.

    Sort data in a range or table (33)

  5. To change the order in which the columns are sorted, select an entry and then click theUp orDown arrow next to theOptionsbutton.

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.

  1. Select a cell in the column you want to sort

  2. On theDatatab, in theSort & Filtergroup, selectCustom Sort.Sort data in a range or table (34)

  3. In theCustom Sortdialog boxunderColumns,select the column that you want to sort.Sort data in a range or table (35)

  4. Under Sort On, select Cell Color, Font Color or Conditional Formatting Icon.

  5. UnderOrder, select the order you want (what you see depends on the type of format you have). Thenselect a cell color, font color, or cell icon.

  6. 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:SelectOn Topfor a column sort, andOn Leftfor a row sort.

    • To move to the bottom or to the right: SelectOn Bottomfor a column sort, andOn Rightfor a row sort.

  7. To specify the next cell color, font color, or icon to sort by, selectAdd Level, and then repeat steps 1- 5.

  • Make sure that you the column in theThen bybox 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.

  1. On theDatatab, in theSort & Filtergroup, click Custom Sort.

    Sort data in a range or table (36)

  2. In the Custom Sortdialog box, clickOptions.

    Sort data in a range or table (37)

  3. In theOptions menu, selectCase sensitive.

    Sort data in a range or table (38)

  4. ClickOK.

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.

  1. Select any cell within the range you want to sort.

  2. On theDatatab, in theSort & Filtergroup, selectCustom Sort.

    Sort data in a range or table (39)

  3. In the Custom Sortdialog box, clickOptions.Sort data in a range or table (40)

  4. UnderOrientation, clickSort left to right Sort data in a range or table (41)

  5. UnderRow, 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. Sort data in a range or table (42)

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

See how it's done

Sort data in a range or table (43)

Need more help?

You can always ask an expert in the Excel Tech Communityor get support inCommunities.

See also

Use the SORTand SORTBYfunctions to automatically sort your data. Also, seeFilter data in an Excel table or range, and Apply conditional formatting in Excel.

Sort data in a range or table (2024)
Top Articles
The Influence of Gender on Leadership Styles: Exploring Research and Theories
Neopets will finally fix its games in $4 million overhaul
Craigslist Livingston Montana
Kostner Wingback Bed
Bj 사슴이 분수
Summit County Juvenile Court
OSRS Fishing Training Guide: Quick Methods To Reach Level 99 - Rune Fanatics
Polyhaven Hdri
Obituaries
Mustangps.instructure
7543460065
Soap2Day Autoplay
My Vidant Chart
Youtube Combe
Sams Gas Price Fairview Heights Il
Mission Impossible 7 Showtimes Near Regal Bridgeport Village
Oppenheimer Showtimes Near Cinemark Denton
General Info for Parents
Hood County Buy Sell And Trade
Playgirl Magazine Cover Template Free
fort smith farm & garden - craigslist
De beste uitvaartdiensten die goede rituele diensten aanbieden voor de laatste rituelen
Grayling Purnell Net Worth
Virginia New Year's Millionaire Raffle 2022
Curry Ford Accident Today
Traveling Merchants Tack Diablo 4
Invitation Homes plans to spend $1 billion buying houses in an already overheated market. Here's its presentation to investors setting out its playbook.
Timeforce Choctaw
Happy Life 365, Kelly Weekers | 9789021569444 | Boeken | bol
Doublelist Paducah Ky
27 Paul Rudd Memes to Get You Through the Week
Understanding Gestalt Principles: Definition and Examples
Myql Loan Login
Skidware Project Mugetsu
Usa Massage Reviews
TMO GRC Fortworth TX | T-Mobile Community
49S Results Coral
Craig Woolard Net Worth
Account Now Login In
R3Vlimited Forum
Workboy Kennel
Ni Hao Kai Lan Rule 34
Mp4Mania.net1
Closest 24 Hour Walmart
About :: Town Of Saugerties
Gt500 Forums
QVC hosts Carolyn Gracie, Dan Hughes among 400 laid off by network's parent company
Cvs Coit And Alpha
Devotion Showtimes Near Showplace Icon At Valley Fair
Ajpw Sugar Glider Worth
Pronósticos Gulfstream Park Nicoletti
Appsanywhere Mst
Latest Posts
Article information

Author: Carmelo Roob

Last Updated:

Views: 5975

Rating: 4.4 / 5 (65 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Carmelo Roob

Birthday: 1995-01-09

Address: Apt. 915 481 Sipes Cliff, New Gonzalobury, CO 80176

Phone: +6773780339780

Job: Sales Executive

Hobby: Gaming, Jogging, Rugby, Video gaming, Handball, Ice skating, Web surfing

Introduction: My name is Carmelo Roob, I am a modern, handsome, delightful, comfortable, attractive, vast, good person who loves writing and wants to share my knowledge and understanding with you.