We often filter data by some criteria in its own worksheet, but if we have two or more worksheets and want to filter data from sheet1 by the criteria in worksheet2 how can we do? If we can filter data by another worksheet, then in our daily work, it will be quite helpful when we have a summary list and filter data by some details by another worksheet. This article will show your two ways to do filter data by another worksheet, you can filter data by Advanced Filter function, or COUNTIF function.
Prepare two worksheets in one Excel file, and sheet1 records the summary of name & class & score, and sheet2 only records the name.
If we only want to filter data in sheet1 by sheet2 column A, how can we do?
Table of Contents
Filter Data Based on Another Worksheet by Advanced Filter Function
Step 1: In tool bar, click on Data->Advanced. Advanced is located just next to Filter icon.
Step 2: In Advanced Filter window, keep default selected option ‘Filter the list, in-place’, in List range, enter the range you want to do filter, in this case enter $A$1:$A$7. Don’t forget to add $ before cell row and column number.
Or you can directly click on button to select filter range by select cells on table directly.
Step 3: In Criteria range, click button to select criteria range on sheet2.
Then we get criteria range on Advanced Filter, see below:
Step 4: Click OK. Then we filter data based on shee2 column A successfully.
Filter Data Based on Another Worksheet by COUNTIF Function
Actually, we can use the COUNTIF function to calculate whether the data in sheet1 column A exists in sheet2 column A, and then use the filter function to filter the values that match the conditions according to sheet2 column A.
Step 1: In cell D2, enter the formula =COUNTIF(Sheet2!$A$1:$A$3,A2).
Step 2: Press Enter. Then we get return value 1. Return value 1 means we can find A2 value in sheet2 range A1 to A3, and this value occurs only once.
Step 3: Copy the cell D2 with formula to other cells like below. Then we get all return values.
Step 4: Do filter on column D. As we want to do filter by the criteria in sheet2 column A, so we only keep the rows which its D column value is 1. Select on D column in sheet1, click on Data->Filter, check on filter value 1, then click OK. Then we get the same result.
- Excel COUNTIF function
The Excel COUNTIF function will count the number of cells in a range that meet a given criteria. This function can be used to count the different kinds of cells with number, date, text values, blank, non-blanks, or containing specific characters.etc.= COUNTIF (range, criteria)…