Sorting and filtering: practice exercises
Ctrl+Shift+L, filter buttons, sort A to Z, SUBTOTAL. 6 exercises on real-looking data, each checked as you go. This lesson is free, with no account needed.
The keys
| What it does | Windows | Excel for Mac |
|---|---|---|
| Undo | Ctrl+ | Cmd+ |
| Filter buttons on or off | Ctrl+ | Control+ |
| Open a heading's filter menu | Alt+ | Option+ |
All the shortcuts in one list, with Windows and Mac keys side by side.
This lesson is done with the tools on a practice sheet in the lesson, just as in Excel, and each task is checked as you go.
How it works
Ctrl+Shift+L turns on filters: a button appears in each heading. Click one (or press Alt+↓ on the heading) to sort the table by that column, or tick just the values you want to see. The other rows are hidden, not deleted, and their row numbers turn blue so you can tell a filter is on.
SUM still adds up hidden rows. SUBTOTAL(9, range) leaves out the rows a filter has hidden, so a total under a filtered table shows the total for what's on screen. Rows you hide yourself still count with 9; SUBTOTAL(109, range) leaves those out too.
=SUBTOTAL(9,D2:D20)
Filters
A filter hides the rows you don't want to see, so you can look at one team, one region, one month.
- Click any cell in the table and press Ctrl+Shift+L (in Excel for Mac, Cmd+Shift+F works too). Each heading gets a ▾ button.
- Click a button, untick (Select all), tick what you want, and press OK.
- Filtered-out rows are hidden, not deleted. The row numbers that are left turn blue, and the button shows a filter symbol.
- To show everything again, choose Clear filter, or press Ctrl+Shift+L to turn filters off.
Sorting
The same button sorts: A to Z for text, smallest to largest for numbers, or the other way round.
Sorting with the button moves whole rows, so each person keeps their own team and sales. Sorting just one column on its own would mix the rows up, which is a classic way to ruin a spreadsheet. If it goes wrong, Ctrl+Z.
Totals that follow a filter
=SUM(D2:D20) adds up every row, hidden or not. =SUBTOTAL(9,D2:D20) leaves out the rows a filter has hidden.
The first number picks the sum: 9 is SUM, 1 AVERAGE, 2 COUNT, 3 COUNTA, 4 MAX, 5 MIN. Put the total a row or two below the table, so it isn't part of the filter.
Rows you hide yourself (right-click, then Hide) still count with 9. Add 100, so 109, to leave those out as well.
What you'll practise
- Turn on filters for this table with Ctrl+Shift+L.
- Sort the table so the biggest sales are at the top: use the filter button on Sales (£) and pick Sort largest to smallest.
- Show only the IT team: open the filter on Team, untick (Select all), tick IT, and press OK.
- Show the Support and Operations teams, and no others.
- The table is filtered to the Finance team. In D13, total the sales you can see with SUBTOTAL(9, …), so the total follows the filter. (SUM would add up the hidden rows too.)
- Two jobs: show only the North region, and sort it so the biggest sales come first.
Guides with worked examples: UNIQUE and FILTER: lists that update themselves · SORT and SORTBY: sorted lists that keep up