How to filter and sort data in Excel
Filtering hides rows that do not match; it does not delete them. Sorting rearranges rows (or, if you choose the option, columns).
To filter a list, select a cell in the range and go to Data > Filter. Click a column header arrow, then either tick the values you want or open Text Filters, Number Filters, or Date Filters and choose a comparison such as Between. In an Excel table, those arrows are already in the header row.
To sort, select a cell in the column and, on the Data tab in the Sort & Filter group, choose Sort A to Z or Sort Z to A (for numbers, Smallest to Largest or Largest to Smallest). To sort by more than one column — for example Department, then Name — select Data > Sort, choose the first column, select Add Level, and add the next column. Microsoft says you can sort by up to 64 columns.
These Data-tab steps apply in Excel for Microsoft 365, Excel for the web, and Excel 2024–2016. If Excel warns that you selected only one column, expand the selection before you sort, or you can scramble the rows.
Filter and sort a list
Turn on a filter and filter a range
- Select any cell inside the data range. For best results, use a single header row and do not mix text and numbers in the same column — Microsoft notes that only one type of filter command is shown per column, based on the most common data type.
- Select Data > Filter. Drop-down arrows appear in the header row.
- Select a column header arrow. To filter by specific values, clear (Select All) and tick the items you want, then select OK.
- To filter by a rule, open Text Filters or Number Filters (or the date equivalent) and choose a comparison such as Between, then enter the criteria and select OK.
- You can filter by more than one column. Microsoft states that filters are additive: each extra filter narrows the rows that are already visible.
- A header that still shows a drop-down arrow means filtering is enabled but not applied on that column (the tooltip says “Showing All”). A filter icon means a filter is applied; hover the header to see the criterion.
Filter a table, then clear or reapply
- If the list is an Excel table, filter arrows are added to the headers automatically. You can also create a table first with Home > Format as Table (Excel for the web includes this path in Microsoft’s filter article).
- Use the header arrow as above. The arrow changes to a filter icon while the filter is on; select that icon to change or clear it.
- To show all rows again, clear the filter from that column, or use the Data tab command to clear filters from the sheet.
- After the underlying data changes or formulas recalculate, reapply the filter so the visible rows stay up to date. Microsoft lists data edits and formula results as reasons a reapplied filter can show a different set of rows.
- The Find dialog only searches rows that are currently displayed. Clear filters first if you need to search the whole list.
Quick sort on one column
- Select a cell in the column you want to sort (select one cell in the list, not a single isolated column, so Excel can keep rows together).
- On the Data tab, in the Sort & Filter group, select Sort A to Z or Sort Z to A for text, Sort Smallest to Largest or Sort Largest to Smallest for numbers, or the matching oldest/newest commands for dates.
- If Excel asks whether to expand the selection, choose the option that keeps entire rows together, unless you really intend to sort only the selected cells.
- If a text sort looks wrong, Microsoft recommends checking that values are all stored as text or all as numbers (not a mix), and removing leading spaces (manually or with
TRIM). Numbers stored as text often sort after real numbers. Blank cells are always placed last, in both ascending and descending sorts.
Sort by more than one column, color, or a custom list
- Select any cell in the range. Microsoft recommends that the range have column headings.
- On the Data tab, in the Sort & Filter group, select Sort.
- In the Sort dialog, under Column, choose the first field in Sort by. Under Sort On, choose Cell Values, or choose Cell Color, Font Color, or Cell Icon to sort by format. Under Order, choose A to Z, Z to A, Smallest to Largest, a date order, or Custom List (for example High, Medium, Low).
- Select Add Level and set the next column (the Then by row). Repeat as needed, up to 64 columns. Use Copy Level, Delete Level, or the up and down arrows to rearrange levels. Entries higher in the list are sorted first.
- Tick My data has headers if the first row is a header so it stays put. Clear that box if the first row is data and must be sorted.
- To sort left to right (reorder columns by a row), open Sort > Options and choose Sort left to right. Microsoft notes that tables do not support left-to-right sorting; convert the table to a range first. Then sort by the header row, usually row 1.
Filter vs sort vs a table
| Action | What it does | Official starting point |
|---|---|---|
| Filter a range | Temporarily hides rows that do not match | Data > Filter, then a header arrow |
| Filter a table | Same idea; arrows are already in the headers | Header arrow, or Home > Format as Table first |
| Sort one column | Reorders all rows by that column | Data tab: Sort A to Z / Sort Z to A (or number/date equivalents) |
| Sort several columns | Groups by the first column, then sorts inside each group | Data > Sort, then Add Level |
| Sort by color or icon | Orders rows by fill, font color, or icon set | Data > Sort, Sort On = color or icon |
| Custom list | Uses a defined order such as High, Medium, Low | Data > Sort, Order > Custom List |
Filtering does not rearrange rows; sorting does. You can filter and then sort the visible rows. Neither action deletes data.
Troubleshooting
- Only part of the row moved when you sorted. Excel may have sorted the current selection instead of the whole list. Undo, select one cell in the list, and sort again, expanding the selection if prompted. Unhide rows and columns first — Microsoft says hidden columns are not moved when you sort columns, and hidden rows are not moved when you sort rows.
- The filter menu shows Text Filters when you expected numbers (or the reverse). The column mixes types, and Excel offers the command for the most common type. Convert the column to one type.
- A number or date sort looks alphabetical. Values are stored as text (sometimes after a leading apostrophe or an import). Convert them to numbers or dates and sort again.
- The header row was sorted into the data. In the Sort dialog, select My data has headers.
- Find cannot locate a value you know is there. Clear the filters; Find only searches displayed rows.
- A sorted list of formulas looks stale. Recalculate and sort again. Microsoft notes that formula results can change after a calculation, so you may need to reapply the sort.
Frequently asked questions
How do I add filter arrows to an Excel range?
Select a cell in the range and choose Data > Filter. Arrows appear in the header row. If the data is already an Excel table, the arrows are there automatically. Click an arrow to filter by values or by a text, number, or date comparison, then select OK.
How do I sort Excel data by two columns?
Select a cell in the list, go to Data > Sort, choose the first column under Sort by, set Sort On and Order, then select Add Level and choose the second column. Microsoft’s example is sorting by Department and then by Employee name. You can add more levels, up to 64 columns.
Why did Excel sort my numbers as if they were text?
The column probably mixes numbers stored as numbers with numbers stored as text, or it contains leading spaces. Microsoft recommends formatting the column consistently as numbers or as text, and removing leading spaces (the TRIM function can help). After the values are a single type, sort again with Smallest to Largest or A to Z, as appropriate.
What’s the difference between filtering and sorting in Excel?
A filter temporarily hides rows that do not meet your criteria; the underlying order of hidden rows is unchanged, and you can clear the filter to see everything again. A sort changes the order of the rows (or, with Sort left to right, the order of the columns). You often use both: filter to a subset, then sort what is visible.
Can I sort or filter in Excel for the web?
Yes. Microsoft includes Excel for the web in the applies-to list for both articles. You can format a range as a table so header buttons appear, then use those buttons to filter or sort, and you can use the Data tab commands when they are available. If a desktop-only option such as a particular custom-list sort is missing, open the workbook in Excel for Windows or Mac to finish the sort.