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 only that 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.

graphics/03fig20.gif


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:

  1. Click any cell in the original list.

  2. Choose Data, Filter, Advanced Filter. The window shown in Figure 3.21 appears.

    Figure 3.21. Filtering a list to a new location does not rely on hiding records.

    graphics/03fig21.jpg


  3. Click the Copy to Another Location option button. This enables the Copy To box.

  4. Click in the Copy To box, and then in some cell on the worksheet to establish the copy-to location.

  5. Fill the Unique Records Only check box.

  6. Click OK to create the filtered list.

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 plenty especially 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:

  1. In some blank cell, enter Branch.

  2. In the cell immediately below, enter Northwest. Below that enter Southeast, and below that enter Central.

  3. Click in any cell in the existing list.

  4. 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).

    Figure 3.22. Any variable names in a criteria range must be identical to those in the list.

    graphics/03fig22.gif


  5. Continue as usual with the Advanced Filter, specifying a Copy To range, and Unique Values if you want.

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 worksheet even 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.

graphics/03fig23.gif


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:

  1. Select any cell in the A1:C21 list.

  2. Choose Data, Filter, Advanced Filter.

  3. Select the Copy to Another Location option.

  4. Click in the Criteria Range box, and drag through E1:E2.

  5. Click in the Copy To box, and then click cell G1.

  6. 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.

    graphics/03fig24.gif




Managing Data with Microsoft Excel
Managing Data with Microsoft Excel
ISBN: 789731002
EAN: N/A
Year: 2003
Pages: 134

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net