Sub topic 5
Turn on AutoFilter
AutoFilter adds a dropdown arrow to each column header. You use these arrows to show only the rows you care about and hide the rest. This chapter covers how to turn AutoFilter on, how it decides which cells belong to your data, what it does to rows, and the errors people hit most often.
This chapter assumes you can open and save workbooks, select cells and columns, and enter basic formulas. It also assumes your data already has a single header row and no blank rows or columns, as set up in the first chapter.
What AutoFilter does
AutoFilter hides rows that do not match a condition. It never deletes data. The hidden rows stay in the worksheet, and clearing the filter brings them back.
Filtering is different from sorting. Sorting changes the order of the rows. Filtering changes which rows are visible and leaves the order alone. You can use both on the same data, and the two do not interfere with each other.
Excel applies a filter to one column at a time, but the conditions on several columns combine. A later chapter covers combining conditions. Here the goal is to get AutoFilter running and understand what it is attached to.
Turn AutoFilter on
Use this sample data in cells A1:D8. The header row is row 1.
| Order | Region | Rep | Amount |
|---|---|---|---|
| 1001 | West | Ana | 1200 |
| 1002 | East | Ben | 450 |
| 1003 | West | Cara | 780 |
| 1004 | North | Dev | 300 |
| 1005 | East | Ana | 1500 |
| 1006 | West | Ben | 520 |
| 1007 | North | Cara | 990 |
To turn AutoFilter on:
- Click any single cell inside the data, for example B3.
- Go to the Data tab and choose Filter.
Dropdown arrows appear on the header cells A1 to D1. You can also press Ctrl+Shift+L on Windows, or Cmd+Shift+F on Mac, to toggle the filter on and off. On the Home tab, Sort & Filter then Filter does the same thing.
Clicking Filter a second time removes the arrows. It also shows any rows the filter had hidden.
How Excel finds the filter range
When you click one cell and turn on AutoFilter, Excel expands outward from that cell until it reaches a completely blank row and a completely blank column on each side. This block is called the current region. The first row of that block becomes the header row.
This has consequences:
- A blank row in the middle of your data ends the region. Rows below the gap are not included, so they are never hidden or shown by the filter.
- A blank column in the middle splits the region the same way.
- If the cell you clicked is already isolated, with blank neighbors, Excel may show an error or ask you to select a range.
You can check the detected region before you turn on the filter. Click a cell in the data and press Ctrl+A once. The highlighted block is what Excel treats as the data. If the highlight stops early, look for a blank row or column.
If you want full control, select the exact range first, including the header row, and then click Filter. Excel uses your selection as written. This is the safest approach when the data sits next to unrelated content.
Use the dropdown menu
Click the arrow on the Region header. The menu has three main parts:
- Sort options at the top, which reorder the rows by that column.
- Filter by Color and a Text Filters, Number Filters, or Date Filters submenu, depending on the type of data in the column.
- A list of checkboxes with every distinct value in the column, plus a Search box above it.
To show only West rows, clear (Select All), tick West, and choose OK. Rows 1002, 1004, 1005, and 1007 disappear. The remaining rows keep their original row numbers, so the row headings read 1, 3, 4, 7 and so on. The row numbers turn blue to show a filter is active. The dropdown arrow on Region also changes to a funnel icon.
The Search box is faster for long lists. Type "we" and the list narrows to values containing that text. Choosing OK filters to the matches.
The column type decides the menu
Excel looks at the values in each column and picks the submenu to match. A column of text gets Text Filters. A column of numbers gets Number Filters. A column of dates gets Date Filters, with checkboxes grouped by year, month, and day.
If a column mixes types, Excel chooses by majority. A column with 90 numbers and 10 numbers stored as text may show Number Filters, and the text-formatted values behave strangely. Part of the fix for that is covered in the troubleshooting chapter. For now, remember that the menu you see is a hint about how Excel reads your column.
Read the status bar
When a filter is active, the status bar at the bottom left shows a message such as "4 of 7 records found". This gives you a quick check that the filter did what you expected. If the message is missing, the filter is not active or the window is too narrow to show it.
Rows stay in the file
Hidden rows still exist. This matters in three ways:
- Formulas still see them.
=SUM(D2:D8)adds all rows, including hidden ones. A later chapter shows how to total only visible rows. - Copying works on visible rows only. If you select a filtered range and copy it, Excel copies only the visible rows. Pasting them elsewhere gives you a clean extract.
- Deleting works on visible rows only. If you select the visible rows and delete the rows, Excel removes only the visible ones. This is a useful way to delete all rows matching a condition, but it is permanent. Save a copy first.
Apply AutoFilter to a specific range by code
If you automate your workbooks with VBA, you can set the range explicitly. This example turns the filter on for A1:D8 and shows only West rows.
Sub FilterWest()
With ActiveSheet
If .AutoFilterMode Then .AutoFilterMode = False
.Range("A1:D8").AutoFilter Field:=2, Criteria1:="West"
End With
End SubField:=2 is the second column of the range, which is Region. The AutoFilterMode line removes any earlier filter so the macro starts clean. You do not need VBA for anything else in this tutorial.
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| Rows below a gap are not filtered | A blank row ended the detected region | Delete the blank row, or select the full range and turn on Filter |
| The dropdown is on the wrong row | Excel took a title row above the data as the header | Select the true header row and the data below it, then turn on Filter |
| A new column has no arrow | The column was added after the filter was set | Turn the filter off and on again with a cell in the data selected |
| The Filter button is greyed out | The sheet is protected, or you are editing a cell | Press Esc, or unprotect the sheet |
| New rows at the bottom are missed | Rows added below the region were not included | Reapply the filter, or use an Excel Table, covered in a later chapter |
One more point catches people. A filter does not update itself when you edit values. If you change a West row to East while the filter shows West, the row stays visible until you reapply the filter. To refresh, go to Data, then Reapply, or press Ctrl+Alt+L.
Merged cells in the header
Merged cells in the header row cause trouble. A merged header spanning two columns gives you only one dropdown arrow, and it filters the first column only. Unmerge the header cells and give each column its own label before you turn on the filter.
Check your understanding
Exercise
Your data in A1:D200 has a blank row at row 120. You click cell B5 and turn on Filter, then filter Region to West. Rows 121 to 200 still show every region. Why, and what are two ways to fix it?
Show answer
Excel expanded from B5 only until it reached the blank row 120, so the filter range was A1:D119. Rows 121 to 200 were never part of it. Fix it by deleting the blank row and reapplying the filter, or by selecting A1:D200 first and then clicking Filter so Excel uses your selection as written.
Exercise
You filter Region to West and then type =SUM(D2:D8) in a cell below the data. Does the result include the hidden East and North rows? How can you tell what the filter currently shows?
Show answer
Yes, SUM includes hidden rows, so the result is the total of all rows. To see what the filter shows, read the status bar message such as "3 of 7 records found", and look for blue row numbers and the funnel icon on the filtered column's arrow.