Download the associated Workbook for this lesson
The Advanced Filter is used when you need to either filter your data down in a way that AutoFilter cannot and/or you want the result of your filtered data to be copied to another area on the Worksheet. The Advanced Filter dialog can be found by going to Data>Filter>Advanced filter.
You will see the option to either Filter the list, in place or Copy to another location. If you opt to Filter the list, in place, your table or list (list range) will be filtered in the same way as AutoFilter would do so. In other words it will hide all rows that do not meet the criteria as specified in the Criteria range: If you opt to Copy to another location your list range that meets the criteria as specified in the Criteria range will be copied to another location on the same Worksheet. The Copy to another location option does not allow you to copy your results to another Worksheet! If you do wish to do this simply opt to Copy to another location on the same Worksheet, then cut and paste the results to another Worksheet.
You may remember that point 2 in Guidelines for creating a table or list was:
Leave at least three blank rows above your headings. These can be used for formulas, critical data etc. You can hide the Rows if you wish.
This is so we can use them for setting a Criteria for an Advanced Filter. When you set a Criteria you refer to it using the Criteria range box. Your criteria range should include the column headings of your list or table. So we simply copy our column headings to the top blank row. It is below these headings that we put our criteria.
Using the list of names example, we would have a copy of our heading Names in, say cell A1.
You could type John in cell A2 and Dave in cell A3.
Select any cell within your table and go to Data>Filter>Advanced Filter.
Select Filter the list in place.
Make sure your list range is correct.
Put A1:A3 in your Criteria range box
Our table would then only display the information for John and Dave. To add more names we would insert some more rows above our data and use these to add the extra names. However, we believe it is better to have the extra rows there to begin with, and as we have said previously, leave at least three rows above your data and hide them.
We could, of course, do exactly the same and use the Copy to another location option, the only thing we would need to do is place a cell reference in the Copy to: box to start our new table in.
We could also extend our criteria to not only show John and Dave's information, but to show only John and Dave IF they are older than age 24. To do this we would put: >24 in the cell directly below our copied heading Age and >24 again in the cell below this. Then apply the Advanced Filter and include the new criteria in the Criteria box ie; A1:D3, where our new criteria for the age is in cells D1:D3. It does not matter that there is no criteria in cells B1:C3 as blank cells would be ignored.
We can also use formulas as our criteria when using Advanced Filter, which can make our filtering capabilities even more complex. However any formula we use:
must evaluate to either TRUE or FALSE.
The formula we use, must use a relative cell reference to the first data cell in column we want to filter.
The range within the formula itself must be an absolute reference.
If we do not apply these three rules the Advanced Filter will not work as expected.
So let's say we have the column heading Pay Rate in cell B6 and we wanted to find the information on the person who has the third largest pay rate. To do this we could use the formula: =B7=LARGE($B$7:$B$27,3) place it in cell B2. Where B7 is our first Pay Rate and $B$7:$B$27 is the entire range below Pay Rate.
When we use the Advanced Filter this time we must not have our column heading Pay Rate in cell B1. We would still refer our Criteria range in the Advanced Filter dialog to: $B$1:$B$2 but we cannot have a column heading in B1. In other words we use the formula cell and a blank cell above it. We can place data in cell B1 but it cannot be a column heading from our table.
We have included a Workbook example of Advanced Filters to give you an idea on how they can be used. There is also some good information in the Excel help under: Filter a list using advanced criteria that is worth reading. As with the use of most formulas in Excel it can take some trial and error before we get the result we want. But as we have said before "making mistakes is a great way to learn".
The other very handy feature of the Advanced Filter is that we can use it to create a list of Unique records only. To do this we simply need to check the Unique record only box and leave the Criteria range box blank. When we use this option though can only use include a single column list range.
It is also possible to create a list of Unique record only that also meet a criteria we have set. To do this we simply refer the Criteria range to a range that contains a criteria.