- Creating Lists
- Sorting Lists
- Working with Names
- Filtering Data with the AutoFilter
- Using the Advanced Filter
- Looking Ahead
Using the Advanced Filter
The Advanced Filter used in Figure 3.20 provides three options that you can't get from AutoFilter:
You can use it to create an entirely new, filtered list.
You can obtain a list that contains unique records onlythat is, only one instance of each possible combination of values.
You have greater control over criteria. For example, you can establish more than two custom criteria that apply to a single column in the list.
Figure 3.20 Filtering a list to a new location does not rely on hiding records.
Column A of Figure 3.20 shows the original, unfiltered list. In column C, you see the new list that the user created with Advanced Filter: a list that consists only of unique names in column A. To get the result you see in column C, do this:
-
Click any cell in the original list.
-
Choose Data, Filter, Advanced Filter. The window shown in Figure 3.21 appears.
-
Click the Copy to Another Location option button. This enables the Copy To box.
-
Click in the Copy To box, and then in some cell on the worksheet to establish the copy-to location.
-
Fill the Unique Records Only check box.
-
Click OK to create the filtered list.
Figure 3.21 Filtering a list to a new location does not rely on hiding records.
CAUTION
Be sure that there's no important data in the columns that the filtered list will occupy (in Figure 3.20, that's columns E through G). The Advanced Filter overwrites existing data in the copy-to columns, either with filtered data or, farther down, with blank cells. Excel does not provide a warning, and there is no Undo command available to take back the filtering action.
TIP
If you click the button (termed a collapse dialog button) on the right edge of any of the three boxes, the dialog box collapses to give you more room on the worksheet. Click the same button in the collapsed dialog box to restore it to the original size.
NOTE
You cannot copy to a location on a different worksheet. If the list you want to filter is on, say, Sheet2, you cannot cause the Advanced Filter to copy filtered records to Sheet3.
Using Criteria with the Advanced Filter
You can specify more criteria for the Advanced Filter than you can with the AutoFilter. Recall that for any column, you can choose one or two criteria using the Custom AutoFilter. For most purposes, this is plentyespecially when you consider that you can use wildcards in the criteria.
But suppose that you need more than two criteria per column, or that the filter you have in mind requires the Advanced Filter for some other reason. In that case, you'll need to specify in another worksheet location the criteria that the Advanced Filter will use. You might want to create a separate, filtered list that contains only records from the Northwest, Southeast, and Central branches. (Note that because this condition requires three criteria on the same field, AutoFilter won't do.) A separate list requires the Advanced Filter, so you would take these steps:
-
In some blank cell, enter Branch.
-
In the cell immediately below, enter Northwest. Below that enter Southeast, and below that enter Central.
-
Click in any cell in the existing list.
-
Choose Data, Filter, Advanced Filter. Click in the Criteria Range box, and then select the four cells you used in steps 1 and 2 (see Figure 3.22).
-
Continue as usual with the Advanced Filter, specifying a Copy To range, and Unique Values if you want.
Figure 3.22 Any variable names in a criteria range must be identical to those in the list.
The result appears in Figure 3.22, in cells G1:I13.
TIP
You can't specify a Copy To range on a different worksheet from the original list. But you can put the Criteria range on a different worksheeteven in a different workbook if you can think of a good reason to do so.
Using Formulas as Filter Criteria
With Advanced Filter, it's also possible to filter a list with the result of a formula as a criterion. Consider the list in A1:C22 of Figure 3.22. Suppose that you wanted to see only those records whose revenue value exceeded the average revenue of all the records. One way to arrange that is to use the Advanced Filter as before, but with a formula as the criterion. Your criteria range could occupy E1:E2, as shown in Figure 3.23.
Figure 3.23 The criterion in cell E2 actually evaluates to a string.
In E2, you enter =">" & AVERAGE(C2:C21). This is the criterion that Advanced Filter will use: It is to return any value that is larger than the average of the Revenue values in C2:C21. Then take the usual steps:
Select any cell in the A1:C21 list.
Choose Data, Filter, Advanced Filter.
Select the Copy to Another Location option.
Click in the Criteria Range box, and drag through E1:E2.
Click in the Copy To box, and then click cell G1.
-
Click OK. The result appears in Figure 3.24.
Figure 3.24 Notice that the filtered list in G1:I9 contains only those records whose revenue exceeds $45,144.38.