toolrota

Sorting and filtering in Excel: AutoFilter, custom sort and the FILTER function

The fastest way to find what you want in a big list is correct sorting and filtering. Steps, dynamic functions and tips that keep data intact.

Serkan Akyürek·Updated ·4 min read
Sorting and filtering in Excel: AutoFilter, custom sort and the FILTER function – Excel

Sorting puts data in order; filtering shows only the rows you care about.

AutoFilter

  1. Select a cell in the header row.
  2. Data > Filter or Ctrl + Shift + L.
  3. Click the arrow in a header and pick criteria.

There are separate filter options for text, numbers and dates: "contains", "greater than", "this month". Filter by colour lets you select coloured cells.

To remove a filter use Data > Clear or press Filter again.

Sorting

  • Select a header cell and sort A to Z or Z to A from Data.
  • Use Data > Sort for multi-column sorting (city first, then amount).
  • Sort numeric columns such as sales from largest to smallest.

Custom sort

For logical orders such as months or priority (High, Medium, Low), use Sort > Order > Custom List.

Keeping data intact

  1. Select the whole table or one cell inside it; Excel detects the region automatically.
  2. Accept "Expand the selection"; otherwise only one column is sorted and rows come apart.
  3. Blank rows and columns split the region; clear them from the data.
  4. If you turn the data into a table with Ctrl + T, filter and sort buttons come automatically (see our Excel tables guide).

Microsoft 365: SORT and FILTER

They produce dynamic results without changing the data in place.

=SORT(A2:C100,3,-1)                        by column 3, descending
=FILTER(A2:C100,B2:B100="London")          rows for London
=FILTER(A2:C100,(B2:B100="London")*(C2:C100>1000),"No results")
=UNIQUE(B2:B100)                           list of distinct cities

The * sign means AND, + means OR. Results update on their own when the source changes.

Advanced filter

For complex conditions, Data > Advanced lets you define a separate criteria range and copy the result elsewhere.

Totals with filtered data

A normal SUM includes hidden rows. To total only the visible ones:

=SUBTOTAL(109,C2:C100)

Common mistakes

  • The filter isn't seeing some rows: there is a blank row in the data range.
  • Numbers stored as text don't sort correctly.
  • No header row: Excel may treat the first data row as the header.

For summary analysis, see our pivot table guide; to delete repeats, our remove duplicates guide.

Step-by-step example: finding the top 10 customers in a sales list

  1. Prepare the table: one header row, no blank rows and no merged cells.
  2. Turn on the filter: select a cell in the header and press Ctrl + Shift + L.
  3. Filter: from the "Region" column choose only "North."
  4. Sort: on the "Sales" column use Sort Largest to Smallest.
  5. Show the top 10: in the "Sales" filter use Number Filters > Top 10.
  6. Get a total: for the total of the results use =SUBTOTAL(109,E2:E500); only visible rows are summed.
  7. Copy the result: select the filtered area and copy it with Alt + ; (select visible cells only) and paste it on another sheet.

A multi-level sort example

To sort first by Region (A–Z), then within the same region by Sales (largest to smallest): Data > Sort > Add Level. Each region's best sales then appear at the top of its own group. You can also sort by a custom list (Monday, Tuesday…) or by cell colour.

Comparing filter types

FilterFor what?
Text filterContains, begins with, equals
Number filterGreater than, between, top N, above average
Date filterThis month, last week, quarter
Colour filterCell or font colour
Search boxA quick keyword
Advanced filterSeveral conditions, copied output

Frequently asked questions

Why does the filter not show some rows? There may be a blank row in the data range; Excel doesn't include what follows a blank row. Convert to a table (Ctrl + T) or select the whole range and turn on the filter (see our Excel tables guide).

How do I clear a filter without deleting? Remove it with Data > Clear; click the filter icon and choose "Clear Filter."

Does sorting break formulas? Relative references can shift when the order changes; before sorting make sure formulas use in-row references or convert them to values.

What should I do to keep the header out of the sort? Tick "My data has headers."

How do I make a filter permanent in a summary report? With a pivot table and slicer (see our pivot table guide).

Share
Published:
Author
Serkan Akyürek

Serkan Akyürek is the founder and author of toolrota; he writes step-by-step guides on Excel, AI, the cloud, personal finance and digital security.