How to Filter by a List of Values in Excel
By ExcelReady TeamUpdated 6 min read
The short answer
To filter by a list in Excel, use FILTER with COUNTIF as the test: =FILTER(A2:C9,COUNTIF(E2:E3,B2:B9)) returns every row whose region appears in the list in E2:E3. COUNTIF gives a count for each row, and any count above zero keeps it. Use =0 to exclude the list instead. In older Excel, use Advanced Filter.
Key takeaways
- =FILTER(data,COUNTIF(list,column)) keeps rows whose value is on the list; add =0 to remove them instead.
- ISNUMBER(MATCH(column,list,0)) is an equal alternative to COUNTIF inside FILTER.
- Put the list in an Excel table so new values are included without editing the formula.
- FILTER needs Excel 2021 or Microsoft 365; older versions can use Advanced Filter or a COUNTIF helper column.
- Matches are not case-sensitive, but stray spaces and numbers stored as text stop a match.
On this page+
To filter by a list in Excel, you need rows whose value matches any item on a separate list: these five product codes, those three regions, the customers on a watch list. Typing one OR condition per item gets long fast. Instead, give FILTER a COUNTIF test that checks every row against the whole list at once. This guide shows that formula, how to exclude a list, and options for older Excel.
All the examples use this sales table in A1:C9, with the regions to keep listed in E2:E3:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Customer | Region | Amount | Keep | |
| 2 | Acme | North | 500 | North | |
| 3 | Bolt | South | 300 | East | |
| 4 | Cora | East | 250 | ||
| 5 | Dyna | West | 400 | ||
| 6 | Elan | North | 150 | ||
| 7 | Fino | South | 600 | ||
| 8 | Gala | East | 350 | ||
| 9 | Hart | West | 200 |
How to filter by a list with FILTER and COUNTIF#
Use COUNTIF as FILTER's test, with the list as the range and the data column as the criteria:
=FILTER(A2:C9,COUNTIF(E2:E3,B2:B9))The result spills four rows: Acme, Cora, Elan and Gala, the North and East customers. Here is how it works:
COUNTIF(E2:E3,B2:B9)asks, for each region in B2:B9, "how many times is this on the Keep list?" It returns one number per row: 1, 0, 1, 0, 1, 0, 1, 0.- FILTER treats any non-zero number as TRUE and 0 as FALSE.
- FILTER returns the rows of A2:C9 where the test is TRUE.
Notice the order: the list goes first in COUNTIF, and the data column goes second. Swap them and you get the wrong counts. FILTER needs Excel 2021 or Microsoft 365. The FILTER function guide and the COUNTIF function guide cover each function on its own, and the article on the FILTER function with AND and OR explains the basics.
The ISNUMBER and MATCH alternative#
ISNUMBER with MATCH does the same job and some people find it easier to read:
=FILTER(A2:C9,ISNUMBER(MATCH(B2:B9,E2:E3,0)))MATCH looks for each region in the list and returns its position, such as 1 or 2, or #N/A when it isn't there. ISNUMBER turns positions into TRUE and #N/A into FALSE. The result is the same four rows. Here the data column comes first, because MATCH asks "where is this value in the list?". In Microsoft 365, XMATCH works too: ISNUMBER(XMATCH(B2:B9,E2:E3)). The ISNUMBER function guide explains why it is so useful for turning errors into FALSE.
Use whichever you prefer. COUNTIF is a little shorter; MATCH reads more like plain English.
How to exclude a list of values#
To remove the rows on the list and keep everything else, test for a count of zero:
=FILTER(A2:C9,COUNTIF(E2:E3,B2:B9)=0)This returns Bolt, Dyna, Fino and Hart: the South and West customers. The MATCH version is =FILTER(A2:C9,NOT(ISNUMBER(MATCH(B2:B9,E2:E3,0)))). Exclusion lists are handy for removing test accounts, internal emails or cancelled orders.
Combine the list with other conditions#
Multiply the list test by another condition to require both. To keep North and East customers with amounts of 300 or more:
=FILTER(A2:C9,(COUNTIF(E2:E3,B2:B9)>0)*(C2:C9>=300))The result is Acme (500) and Gala (350). The >0 turns the counts into TRUE or FALSE before multiplying, which keeps the test clean even if a value appears twice on the list. The guide to FILTER with multiple criteria explains how * means AND and + means OR. For partial text matches instead of a list, see how to filter rows that contain text.
To total the matching rows instead of listing them, wrap the result: =SUM(FILTER(C2:C9,COUNTIF(E2:E3,B2:B9))) returns 1,250.
Make the list grow automatically#
Turn the list into an Excel table so the formula picks up new values. Select E1:E3, press Ctrl+T (Mac: ⌘T) and name the table Keep. Then write:
=FILTER(A2:C9,COUNTIF(Keep[Keep],B2:B9))Type "South" under the table and the filter result updates at once. Add a third argument to show a message when nothing matches: =FILTER(A2:C9,COUNTIF(E2:E3,B2:B9),"No matches"). Without it, an empty result shows #CALC!.
Filter by a list in older Excel#
Without FILTER, you have two good options:
Advanced Filter#
- Give the list the same header as the data column: change E1 from "Keep" to Region.
- Click inside the data and choose Data > Advanced (in the Sort & Filter group).
- Set the List range to A1:C9 and the Criteria range to E1:E3.
- Choose Copy to another location if you want the result elsewhere, then click OK.
Advanced Filter treats each row of the criteria range as an OR condition. It doesn't update by itself, so run it again when the data changes.
A COUNTIF helper column#
Add a column D with =COUNTIF($E$2:$E$3,B2)>0 and fill it down. Then turn on the filter buttons (Windows: Ctrl+Shift+L; Mac: ⌘⇧F) and filter column D for TRUE. This works in every version of Excel and is easy to check.
Why filter by list returns the wrong rows#
When rows are missing, the values don't match exactly. Check these:
- Extra spaces. "North " with a trailing space doesn't match "North". Clean both sides with TRIM.
- Numbers stored as text. Product code 1050 as a number doesn't match "1050" as text. Make both the same type.
- Arguments swapped. In COUNTIF the list comes first; in MATCH the data column comes first.
- Ranges of different heights. The test range (B2:B9) must have as many rows as the data (A2:C9), or FILTER shows #VALUE!.
Matching is not case-sensitive, so "north" matches "North". To show the matches as one comma-separated cell instead of rows, see how to list matches in one cell.
Practise it#
Filtering by a list combines two skills: FILTER for returning rows, and COUNTIF for testing each row. Practise the FILTER function in a live spreadsheet, then practise COUNTIF to get comfortable with ranges and criteria. Each lesson checks your formula instantly. Then try the exercise on this page to filter the sales table by the Keep list.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
Show only the customers in the regions listed in E2:E3. In G2, type =FILTER(A2:C9,COUNTIF(E2:E3,B2:B9)) and press Enter.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Amount | Keep | ||||||
| 2 | North | |||||||
| 3 | East | |||||||
| 4 | ||||||||
| 5 | ||||||||
| 6 | ||||||||
| 7 | ||||||||
| 8 | ||||||||
| 9 | ||||||||
| 10 | ||||||||
| 11 | ||||||||
| 12 |
Tip: FILTER needs the rows to return (A2:C9) and a test. COUNTIF(E2:E3,B2:B9) counts each region in the Keep list, and any count above 0 keeps the row. Four rows spill: Acme, Cora, Elan and Gala.
Practise this in a lesson
Frequently asked questions
How do I filter a table by a list of values in Excel?
Use =FILTER(data,COUNTIF(list,column)), where list is the cells holding the values you want and column is the matching column of the data. Every row whose value is on the list is returned.
How do I exclude a list of values with FILTER?
Compare the COUNTIF result with zero: =FILTER(A2:C9,COUNTIF(E2:E3,B2:B9)=0). Rows whose value is not on the list are returned.
Can I filter by a list without the FILTER function?
Yes. Use Data > Advanced with your list as the criteria range, or add a helper column with =COUNTIF(list,B2)>0 and filter that column for TRUE with the normal filter buttons.
Why does FILTER by list return #CALC!?
#CALC! means nothing matched, so FILTER had no rows to return. Add a third argument, such as "No matches", or check the list for spaces and typos.
Is filtering by a list case-sensitive?
No. COUNTIF and MATCH ignore capitals, so north on the list matches North in the data. Spaces do matter, so clean both sides with TRIM if rows are missing.