To filter a range of cells by using complex criteria (criteria: Conditions you specify to limit which records are included in the result set of a query. For example, the following criterion selects records for which the value for the Order Amount field is greater than 30,000: Order Amount > 30000.), use the Advanced command in the Sort & Filter group on the Data tab. The Advanced command works differently from the Filter command in several important ways. Using the equal sign to type text or a valueBecause the equal sign (=) is used to indicate a formula when you type text or a value in a cell, Excel evaluates what you type; however, this may cause unexpected filter results. To indicate an equality comparison operator for either text or a value, type the criteria as a string expression in the appropriate cell in the criteria range: =''=entry'' Where entry is the text or value you want to find. For example: What you type in the cell | What Excel evaluates and displays |
---|
="=Davolio" | =Davolio | ="=3000" | =3000 |
Considering case-sensitivityWhen filtering text data, Excel does not distinguish between uppercase and lowercase characters. However, you can use a formula to perform a case-sensitive search. Using pre-defined namesYou can name a range Criteria, and the reference for the range will appear automatically in the Criteria range box. You can also define the name Database for the range of data to be filtered and define the name Extract for the area where you want to paste the rows, and these ranges will appear automatically in the List range and Copy to boxes, respectively. Creating criteria by using a formulaYou can use a calculated value that is the result of a formula (formula: A sequence of values, cell references, names, functions, or operators in a cell that together produce a new value. A formula always begins with an equal sign (=).) as your criterion. Remember the following important points:
Filter by using multiple criteria in one column where any criteria can be true Boolean logic: (Salesperson = "Davolio" OR Salesperson = "Buchanan") - Insert at least three blank rows above the range that can be used as a criteria range. The criteria range must have column labels. Make sure that there is at least one blank row between the criteria values and the range.
The example may be easier to understand if you copy it to a blank worksheet.
| A | B | C |
---|
Type | Salesperson | Sales |
---|
| | | | | | | | | | | | Type | Salesperson | Sales |
---|
Beverages | Suyama | $5122 | Meat | Davolio | $450 | produce | Buchanan | $6328 | Produce | Davolio | $6544 |
|
- To find rows that meet multiple criteria for one column, type the criteria directly below each other in separate rows of the criteria range. In the example, you would enter:
| A | B | C |
---|
1 | Type | Salesperson | Sales |
---|
2 | | ="=Davolio" | |
---|
3 | | ="=Buchanan" | |
---|
- Click a cell in the range. In the example, you would click any cell in the range, A6:C10.
- On the Data tab, in the Sort & Filter group, click Advanced.
- Do one of the following:
- To filter the range by hiding rows that don't match your criteria, click Filter the list, in-place.
- To filter the range by copying rows that match your criteria to another area of the worksheet, click Copy to another location, click in the Copy to box, and then click the upper-left corner of the area where you want to paste the rows.
Tip When you copy filtered rows to another location, you can specify which columns to include in the copy operation. Before filtering, copy the column labels for the columns that you want to the first row of the area where you plan to paste the filtered rows. When you filter, enter a reference to the copied column labels in the Copy to box. The copied rows will then include only the columns for which you copied the labels.
- In the Criteria range box, enter the reference for the criteria range, including the criteria labels. In the example, you would enter $A$1:$C$3.
To move the Advanced Filter dialog box out of the way temporarily while you select the criteria range, click Collapse Dialog . - In the example, the filtered result for the range of data would be:
| A | B | C |
---|
6 | Type | Salesperson | Sales |
---|
8 | Meat | Davolio | $450 |
---|
9 | produce | Buchanan | $6,328 |
---|
10 | Produce | Davolio | $6,544 |
---|
Filter by using multiple criteria in multiple columns where all criteria must be trueBoolean logic: (Type = "Produce" AND Sales > 1000) - Insert at least three blank rows above the range that can be used as a criteria range. The criteria range must have column labels. Make sure that there is at least one blank row between the criteria values and the range.
The example may be easier to understand if you copy it to a blank worksheet.
| A | B | C |
---|
Type | Salesperson | Sales |
---|
| | | | | | | | | | | | Type | Salesperson | Sales |
---|
Beverages | Suyama | $5122 | Meat | Davolio | $450 | produce | Buchanan | $6328 | Produce | Davolio | $6544 |
|
- To find rows that meet multiple criteria in multiple columns, type all of the criteria in the same row of the criteria range. In the example, you would enter:
| A | B | C |
---|
1 | Type | Salesperson | Sales |
---|
2 | ="=Produce" | | >1000 |
---|
- Click a cell in the range. In the example, you would click any cell in the range, A6:C10.
- On the Data tab, in the Sort & Filter group, click Advanced.
- Do one of the following:
- To filter the range by hiding rows that don't match your criteria, click Filter the list, in-place.
- To filter the range by copying rows that match your criteria to another area of the worksheet, click Copy to another location, click in the Copy to box, and then click the upper-left corner of the area where you want to paste the rows.
Tip When you copy filtered rows to another location, you can specify which columns to include in the copy operation. Before filtering, copy the column labels for the columns that you want to the first row of the area where you plan to paste the filtered rows. When you filter, enter a reference to the copied column labels in the Copy to box. The copied rows will then include only the columns for which you copied the labels.
- In the Criteria range box, enter the reference for the criteria range, including the criteria labels. In the example, you would enter $A$1:$C$2.
To move the Advanced Filter dialog box out of the way temporarily while you select the criteria range, click Collapse Dialog . - In the example, the filtered result for the range of data would be:
| A | B | C |
---|
6 | Type | Salesperson | Sales |
---|
9 | produce | Buchanan | $6,328 |
---|
10 | Produce | Davolio | $6,544 |
---|
Filter by using multiple criteria in multiple columns where any criteria can be trueBoolean logic: (Type = "Produce" OR Salesperson = "Davolio") - Insert at least three blank rows above the range that can be used as a criteria range. The criteria range must have column labels. Make sure that there is at least one blank row between the criteria values and the range.
The example may be easier to understand if you copy it to a blank worksheet.
| A | B | C |
---|
Type | Salesperson | Sales |
---|
| | | | | | | | | | | | Type | Salesperson | Sales |
---|
Beverages | Suyama | $5122 | Meat | Davolio | $450 | produce | Buchanan | $6328 | Produce | Davolio | $6544 |
|
- To find rows that meet multiple criteria in multiple columns, where any criteria can be true, type the criteria in the different columns and rows of the criteria range. In the example, you would enter:
| A | B | C |
---|
1 | Type | Salesperson | Sales |
---|
2 | ="=Produce" | | |
---|
3 | | ="=Buchanan" | |
---|
- Click a cell in the range. In the example, you would click any cell in the range, A6:C10.
- On the Data tab, in the Sort & Filter group, click Advanced.
- Do one of the following:
- To filter the range by hiding rows that don't match your criteria, click Filter the list, in-place.
- To filter the range by copying rows that match your criteria to another area of the worksheet, click Copy to another location, click in the Copy to box, and then click the upper-left corner of the area where you want to paste the rows.
Tip When you copy filtered rows to another location, you can specify which columns to include in the copy operation. Before filtering, copy the column labels for the columns that you want to the first row of the area where you plan to paste the filtered rows. When you filter, enter a reference to the copied column labels in the Copy to box. The copied rows will then include only the columns for which you copied the labels.
- In the Criteria range box, enter the reference for the criteria range, including the criteria labels. In the example, you would enter $A$1:$B$3.
To move the Advanced Filter dialog box out of the way temporarily while you select the criteria range, click Collapse Dialog . - In the example, the filtered result for the range of data would be:
| A | B | C |
---|
6 | Type | Salesperson | Sales |
---|
9 | produce | Buchanan | $6,328 |
---|
10 | Produce | Davolio | $6,544 |
---|
Filter by using multiple sets of criteria where each set includes criteria for multiple columnsBoolean logic: ( (Salesperson = "Davolio" AND Sales >3000) OR (Salesperson = "Buchanan" AND Sales > 1500) ) - Insert at least three blank rows above the range that can be used as a criteria range. The criteria range must have column labels. Make sure that there is at least one blank row between the criteria values and the range.
The example may be easier to understand if you copy it to a blank worksheet.
| A | B | C |
---|
Type | Salesperson | Sales |
---|
| | | | | | | | | | | | Type | Salesperson | Sales |
---|
Beverages | Suyama | $5122 | Meat | Davolio | $450 | produce | Buchanan | $6328 | Produce | Davolio | $6544 |
|
- To find rows that meet multiple sets of criteria, where each set includes criteria for multiple columns, type each set of criteria in separate columns and rows. In the example, you would enter:
| A | B | C |
---|
1 | Type | Salesperson | Sales |
---|
2 | | ="=Davolio" | >3000 |
---|
3 | | ="=Buchanan" | >1500 |
---|
- Click a cell in the range. In the example, you would click any cell in the range, A6:C10.
- On the Data tab, in the Sort & Filter group, click Advanced.
- Do one of the following:
- To filter the range by hiding rows that don't match your criteria, click Filter the list, in-place.
- To filter the range by copying rows that match your criteria to another area of the worksheet, click Copy to another location, click in the Copy to box, and then click the upper-left corner of the area where you want to paste the rows.
Tip When you copy filtered rows to another location, you can specify which columns to include in the copy operation. Before filtering, copy the column labels for the columns that you want to the first row of the area where you plan to paste the filtered rows. When you filter, enter a reference to the copied column labels in the Copy to box. The copied rows will then include only the columns for which you copied the labels.
- In the Criteria range box, enter the reference for the criteria range, including the criteria labels. In the example, you would enter $A$1:$C$3.
To move the Advanced Filter dialog box out of the way temporarily while you select the criteria range, click Collapse Dialog . - In the example, the filtered result for the range of data would be:
| A | B | C |
---|
6 | Type | Salesperson | Sales |
---|
9 | produce | Buchanan | $6,328 |
---|
10 | Produce | Davolio | $6,544 |
---|
Filter by using multiple sets of criteria where each set includes criteria for one columnBoolean logic: ( (Sales > 6000 AND Sales < 6500 ) OR (Sales < 500) ) - Insert at least three blank rows above the range that can be used as a criteria range. The criteria range must have column labels. Make sure that there is at least one blank row between the criteria values and the range.
The example may be easier to understand if you copy it to a blank worksheet.
| A | B | C |
---|
Type | Salesperson | Sales |
---|
| | | | | | | | | | | | Type | Salesperson | Sales |
---|
Beverages | Suyama | $5122 | Meat | Davolio | $450 | produce | Buchanan | $6328 | Produce | Davolio | $6544 |
|
- To find rows that meet multiple sets of criteria, where each set includes criteria for one column, include multiple columns with the same column heading. In the example, you would enter:
| A | B | C | D |
---|
1 | Type | Salesperson | Sales | Sales |
---|
2 | | | >6000 | <6500 |
---|
3 | | | <500 | |
---|
- Click a cell in the range. In the example, you would click any cell in the range, A6:C10.
- On the Data tab, in the Sort & Filter group, click Advanced.
- Do one of the following:
- To filter the range by hiding rows that don't match your criteria, click Filter the list, in-place.
- To filter the range by copying rows that match your criteria to another area of the worksheet, click Copy to another location, click in the Copy to box, and then click the upper-left corner of the area where you want to paste the rows.
Tip When you copy filtered rows to another location, you can specify which columns to include in the copy operation. Before filtering, copy the column labels for the columns that you want to the first row of the area where you plan to paste the filtered rows. When you filter, enter a reference to the copied column labels in the Copy to box. The copied rows will then include only the columns for which you copied the labels.
- In the Criteria range box, enter the reference for the criteria range, including the criteria labels. In the example, you would enter $A$1:$D$3.
To move the Advanced Filter dialog box out of the way temporarily while you select the criteria range, click Collapse Dialog . - In the example, the filtered result for the range of data would be:
| A | B | C |
---|
6 | Type | Salesperson | Sales |
---|
8 | Meat | Davolio | $450 |
---|
9 | produce | Buchanan | $6,328 |
---|
Filter by using wildcard criteria to find text values that share some characters but not othersTo find text values that share some characters but not others, do one or more of the following: - Type one or more characters without an equal sign (=) to find rows with a text value in a column that begin with those characters. For example, if you type the text Dav as a criterion, Excel finds "Davolio," "David," and "Davis."
- Use a wildcard character.
Use | To find |
---|
? (question mark) | Any single character For example, sm?th finds "smith" and "smyth" | * (asterisk) | Any number of characters For example, *east finds "Northeast" and "Southeast" | ~ (tilde) followed by ?, *, or ~ | A question mark, asterisk, or tilde For example, fy91~? finds "fy91?" |
- Insert at least three blank rows above the range that can be used as a criteria range. The criteria range must have column labels. Make sure that there is at least one blank row between the criteria values and the range.
The example may be easier to understand if you copy it to a blank worksheet.
| A | B | C |
---|
Type | Salesperson | Sales |
---|
| | | | | | | | | | | | Type | Salesperson | Sales |
---|
Beverages | Suyama | $5122 | Meat | Davolio | $450 | produce | Buchanan | $6328 | Produce | Davolio | $6544 |
|
- In the rows below the column labels, type the criteria that you want to match. In the example, you would enter:
| A | B | C |
---|
1 | Type | Salesperson | Sales |
---|
2 | Me | | |
---|
3 | | ="=?u*" | |
---|
- Click a cell in the range. In the example, you would click any cell in the range, A6:C10.
- On the Data tab, in the Sort & Filter group, click Advanced.
- Do one of the following:
- To filter the range by hiding rows that don't match your criteria, click Filter the list, in-place.
- To filter the range by copying rows that match your criteria to another area of the worksheet, click Copy to another location, click in the Copy to box, and then click the upper-left corner of the area where you want to paste the rows.
Tip When you copy filtered rows to another location, you can specify which columns to include in the copy operation. Before filtering, copy the column labels for the columns that you want to the first row of the area where you plan to paste the filtered rows. When you filter, enter a reference to the copied column labels in the Copy to box. The copied rows will then include only the columns for which you copied the labels.
- In the Criteria range box, enter the reference for the criteria range, including the criteria labels. In the example, you would enter $A$1:$B$3.
To move the Advanced Filter dialog box out of the way temporarily while you select the criteria range, click Collapse Dialog . - In the example, the filtered result for the range of data would be:
| A | B | C |
---|
6 | Type | Salesperson | Sales |
---|
7 | Beverages | Suyama | $5,122 |
---|
8 | Meat | Davolio | $450 |
---|
9 | produce | Buchanan | $6,328 |
---|
Filter by using a formula for values greater than the average of all values in the data range- Insert at least three blank rows above the range that can be used as a criteria range. The criteria range must have column labels. Make sure that there is at least one blank row between the criteria values and the range.
The example may be easier to understand if you copy it to a blank worksheet.
| A | B | C |
---|
Type | Salesperson | Sales |
---|
| | | | | | | | | | | | Type | Salesperson | Sales |
---|
Beverages | Suyama | $5122 | Meat | Davolio | $450 | produce | Buchanan | $6328 | Produce | Davolio | $6544 |
|
- In the rows below the column labels, type the criteria that you want to match as a formula that finds a value in the Sales column greater than the average of all the Sales values. In the example, you would enter:
| A | B | C | D |
---|
1 | Type | Salesperson | Sales | Calculated Average |
---|
2 | | | | =C7>AVERAGE($C$7:$C$10) |
---|
- Click a cell in the range. In the example, you would click any cell in the range, A6:C10.
- On the Data tab, in the Sort & Filter group, click Advanced.
- Do one of the following:
- To filter the range by hiding rows that don't match your criteria, click Filter the list, in-place.
- To filter the range by copying rows that match your criteria to another area of the worksheet, click Copy to another location, click in the Copy to box, and then click the upper-left corner of the area where you want to paste the rows.
Tip When you copy filtered rows to another location, you can specify which columns to include in the copy operation. Before filtering, copy the column labels for the columns that you want to the first row of the area where you plan to paste the filtered rows. When you filter, enter a reference to the copied column labels in the Copy to box. The copied rows will then include only the columns for which you copied the labels.
- In the Criteria range box, enter the reference for the criteria range, including the criteria labels. In the example, you would enter $D$1:$D$2.
To move the Advanced Filter dialog box out of the way temporarily while you select the criteria range, click Collapse Dialog . - In the example, the filtered result for the range of data would be:
| A | B | C |
---|
6 | Type | Salesperson | Sales |
---|
7 | Beverages | Suyama | $5,122 |
---|
9 | produce | Buchanan | $6,328 |
---|
10 | Produce | Davolio | $6,544 |
---|
Filter by using a formula for text in a case-sensitive search - Insert at least three blank rows above the range that can be used as a criteria range. The criteria range must have column labels. Make sure that there is at least one blank row between the criteria values and the range.
The example may be easier to understand if you copy it to a blank worksheet.
| A | B | C |
---|
Type | Salesperson | Sales |
---|
| | | | | | | | | | | | Type | Salesperson | Sales |
---|
Beverages | Suyama | $5122 | Meat | Davolio | $450 | produce | Buchanan | $6328 | Produce | Davolio | $6544 |
|
- In the rows below the column labels, type the criteria that you want to match as a formula by using the EXACT function to perform a case-sensitive search . In the example, you would enter:
| A | B | C | D |
---|
1 | Type | Salesperson | Sales | Exact Match |
---|
2 | | | | =EXACT(A7, "Produce") |
---|
- Click a cell in the range. In the example, you would click any cell in the range, A6:C10.
- On the Data tab, in the Sort & Filter group, click Advanced.
- Do one of the following:
- To filter the range by hiding rows that don't match your criteria, click Filter the list, in-place.
- To filter the range by copying rows that match your criteria to another area of the worksheet, click Copy to another location, click in the Copy to box, and then click the upper-left corner of the area where you want to paste the rows.
Tip When you copy filtered rows to another location, you can specify which columns to include in the copy operation. Before filtering, copy the column labels for the columns that you want to the first row of the area where you plan to paste the filtered rows. When you filter, enter a reference to the copied column labels in the Copy to box. The copied rows will then include only the columns for which you copied the labels.
- In the Criteria range box, enter the reference for the criteria range, including the criteria labels. In the example, you would enter $D$1:$D$2.
To move the Advanced Filter dialog box out of the way temporarily while you select the criteria range, click Collapse Dialog . - In the example, the filtered result for the range of data would be:
| A | B | C |
---|
6 | Type | Salesperson | Sales |
---|
10 | Produce | Davolio | $6,544 |
---|
|