Sometimes we may need to search for certain data to work with. For this purpose, we have to maintain several criteria. But when the dataset is huge, it is really hard to find what we are looking for. Luckily, Excel has its own functions and features to accomplish this objective. In this article, we will show you how to extract data from Excel based on criteria using 6 quick and convenient methods. So, let’s explore the entire article to understand the topic properly.
How to Extract Data Based on Criteria from Excel: 6 Ways
For ease of understanding, we are going to use a List of Students with Their Obtained Marks. This dataset contains the ID, Name, and their corresponding Marks and Departments in columns B, C, D, and E respectively.
Note: This is a basic dataset to keep things simple. In a practical scenario, you may encounter a much larger and more complex dataset.
Now, we’ll utilize this dataset to extract data based on criteria from Excel. So, let’s explore them one by one.
Not to mention, here, we have used Microsoft Excel 365 version, you may use any other version according to your convenience. Please leave a comment if any part of this article does not work in your version.
1. Implementing Array Formula to Extract Data Based on Range Criteria from Excel
From the following dataset as an example, we will describe to you the process of extracting data based on range. Suppose, from the dataset, we only want to retrieve the student details who got Marks from 80 to 100.
The steps to extract data based on a particular range using the Array formula are given below.
Steps:
- First, store the condition in other cells to work with those later. That means as we will be extracting students’ details who got Marks from 80 to 100, we stored 80 as the Start Value and 100 as the End Value in cells H4 and H5 respectively. Also, we need to store the column from where we will look for our stored values. Meaning that Marks 80 and 100 are in the Marks column which is the 3rd column in our dataset, so we stored 3 as the Column value in cell H6.
- Then, make an output range in cells in the B18:E22 range.
- Second, in another cell, where you want the result (we wanted our result in cell B19), write the following formula,
=INDEX($B$5:$E$14,SMALL(IF((INDEX($B$5:$E$14,,$H$6)<=$H$5)*(INDEX($B$5:$E$14,,$H$6)>=$H$4),MATCH(ROW($B$5:$E$14),ROW($B$5:$E$14)),""),ROWS(B19:$B$19)),COLUMNS($A$1:A1))
Formula Breakdown
- INDEX($B$5:$E$14,,$H$6)
- Output: {60;30;80;55;87;95;100;42;25;18}
- Explanation: The INDEX Function usually returns a single value or an entire column or row from a given cell range. 3 is stored in the Cell $H$6, so it returns the entire column no 3 (Marks column) from the whole range of the dataset ($B$5:$E$14) as output.
- INDEX($B$5:$E$14,,$H$6)<=$H$5 -> becomes,
- {60;30;80;55;87;95;100;42;25;18}<=100
- Output: {TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE}
- Explanation: We stored 100 in the Cell $H$5. As all of the values are less than 100 ($H$5), so it returns a column full of TRUE.
Similarly,
- INDEX($B$5:$E$14,,$H$6)>=$H$4 -> becomes,
- {60;30;80;55;87;95;100;42;25;18}>=80
- Output: {FALSE;FALSE;TRUE;FALSE;TRUE;TRUE;TRUE;FALSE;FALSE;FALSE}
- Explanation: We stored 80 in the Cell $H$4. So it returns TRUE when the value from the column is equal or greater than 80; otherwise, it returns FALSE.
- (INDEX($B$5:$E$14,,$H$6)<=$H$5)*(INDEX($B$5:$E$14,,$H$6)>=$H$4) -> becomes,
- {TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE;TRUE}*{FALSE;FALSE;TRUE;FALSE;TRUE;TRUE;TRUE;FALSE;FALSE;FALSE}
- Output: {0;0;1;0;1;1;1;0;0;0}
- Explanation: Boolean values have numerical equivalents, TRUE = 1 and FALSE = 0 (zero). They are converted when performing an arithmetic operation in a formula.
- ROW($B$5:$E$14)
- Output: {5;6;7;8;9;10;11;12;13;14}
- Explanation: The ROW function calculates the row number of a cell reference.
- MATCH(ROW($B$5:$E$14),ROW($B$5:$E$14)) -> becomes,
- MATCH({5;6;7;8;9;10;11;12;13;14},{5;6;7;8;9;10;11;12;13;14})
- Output: {1; 2; 3; 4; 5; 6; 7; 8; 9; 10}
- Explanation: The MATCH function returns the relative position of an item in an array or cell reference that matches a specified value in a specific order.
- IF((INDEX($B$5:$E$14,,$H$6)<=$H$5)*(INDEX($B$5:$E$14,,$H$6)>=$H$4),MATCH(ROW($B$5:$E$14),ROW($B$5:$E$14)),””) -> becomes,
- IF({0;0;1;0;1;1;1;0;0;0}),{1; 2; 3; 4; 5; 6; 7; 8; 9; 10},””)
- Output: {“”; “”; 3; “”; 5; 6; 7; “”; “”; “”}
- Explanation: The IF function returns one value if the logical test is TRUE and another value if the logical test is FALSE.
- SMALL(IF((INDEX($B$5:$E$14,,$H$6)<=$H$5)*(INDEX($B$5:$E$14,,$H$6)>=$H$4),MATCH(ROW($B$5:$E$14),ROW($B$5:$E$14)),””),) -> becomes,
- SMALL({“”; “”; 3; “”; 5; 6; 7; “”; “”; “”},ROWS(B19:$B$19)) -> becomes,
- SMALL({“”; “”; 3; “”; 5; 6; 7; “”; “”; “”},1)
- Output: 3
- Explanation: The SMALL function returns the k-th smallest value from a group of numbers. 3 is the smallest in this group.
- INDEX($B$5:$E$14,SMALL(IF((INDEX($B$5:$E$14,,$H$6)<=$H$5)*(INDEX($B$5:$E$14,,$H$6)>=$H$4),MATCH(ROW($B$5:$E$14),ROW($B$5:$E$14)),””),ROWS(B19:$B$19)),COLUMNS($A$1:A1)) -> becomes,
- INDEX($B$5:$E$14,3,,1)
- Output: {3; “Johnny”, 80, “Biology”}
- Explanation: The INDEX function returns a value from a cell range($B$5:$E$14), specified by the value based on a row and column number.
- Thirdly, press ENTER on your keyboard.
Then, you will get the first extracted data that matches your condition in the result cell. E.g. Johnny whose ID is 3 got 80 marks in Biology and his record is stored in the dataset ahead of others, so we got Johnny’s ID 3 in the result cell (cell B19).
- Now, drag around the columns and rows by Fill Handle to retrieve the details of only the students who got Marks from 80 to 100.
Read More: How to Extract Data from Cell in Excel
2. Incorporating Array Formula to Extract Data from Excel Based on Multiple Conditions
In the above section, we extracted data based on a given range. But in this section, we will show you how to extract data based on multiple conditions.
Look at the same dataset as before but here instead of storing a range of values (marks 80 to 100) as a condition, we stored multiple conditions such as retrieving students’ details from both Chemistry and Biology departments.
The steps to extract data based on multiple conditions using the array formula are given below.
Steps:
- Firstly, store the conditions in other cells to work with those later. That means as we will be extracting students’ details from the Chemistry and Biology departments, we stored Chemistry and Biology in cells G5 and G6 respectively.
- Secondly, in another cell, where you want the result (we wanted our result in cell B19), write the following formula,
=INDEX($B$5:$E$14,SMALL(IF(COUNTIF($G$5:$G$6,$E$5:$E$14),MATCH(ROW($B$5:$E$14),ROW($B$5:$E$14)),""),ROWS(B19:$B$19)),COLUMNS($B$5:B5))
Formula Breakdown
- COUNTIF($G$5:$G$6,$E$5:$E$14) -> becomes,
- COUNTIF({“Chemistry”;“Biology”},{“Math”;“Physics”;“Biology”;“Chemistry”;“Physics”;“Physics”;“Math”;“Chemistry”;“Math”;“Biology”}
- Output: {0;0;1;1;0;0;0;1;0;1}
- Explanation: The COUNTIF function allows us to identify cells in the range $G$5:$G$6 that equals $E$5:$E$14.
- IF(COUNTIF($G$5:$G$6,$E$5:$E$14),MATCH(ROW($B$5:$E$14),ROW($B$5:$E$14)),””) -> becomes,
- IF({0;0;1;1;0;0;0;1;0;1},MATCH(ROW($B$5:$E$14),ROW($B$5:$E$14)),””) -> becomes,
- IF({0;0;1;1;0;0;0;1;0;1},{1; 2; 3; 4; 5; 6; 7; 8; 9; 10},””)
- Output: {“”; “”; 3; 4; “”; “”;“”; 8; “”;10}
- Explanation: The IF function has three arguments, the first one must be a logical expression. If the expression evaluates to TRUE then one thing happens (argument 2) and if FALSE another thing happens (argument 3). The logical expression was calculated in step 1, TRUE equals 1, and FALSE equals 0 (zero). Row no 3, 4, 8, and 10 evaluate TRUE (1).
- SMALL(IF(COUNTIF($G$5:$G$6,$E$5:$E$14),MATCH(ROW($B$5:$E$14),ROW($B$5:$E$14)),””),ROWS(B19:$B$19)) -> becomes,
- SMALL({“”; “”; 3; 4; “”; “”;“”; 8; “”;10},ROWS(B19:$B$19)) -> becomes,
- SMALL({“”; “”; 3; 4; “”; “”;“”; 8; “”;10},1)
- Output: 3
- Explanation: The SMALL function returns the k-th smallest value from a group of numbers. 3 is the smallest in this group.
- INDEX($B$5:$E$14, SMALL(IF(COUNTIF($G$5:$G$6,$E$5:$E$14),MATCH(ROW($B$5:$E$14),ROW($B$5:$E$14)),””),ROWS(B19:$B$19)),COLUMNS($B$5:B5)) -> becomes,
- INDEX($B$5:$E$14, 3, COLUMNS($B$5:B5)) -> becomes,
- INDEX($B$5:$E$14, 3, 1)
- Output: {3; “Johnny”, 80, “Biology”}
- Explanation: The INDEX function returns a value from a cell range($B$5:$E$14), specified by the value based on a row and column number.
- Thirdly, press ENTER on your keyboard.
Later, you will get the first extracted data that matches your conditions in the result cell. E.g. Johnny whose ID is 3 is from the Biology department and his record is stored in the dataset ahead of others, so we got Johnny’s ID 3 in the result cell.
- Afterward, drag around the columns and rows by Fill Handle to retrieve the details of only the students who are from the Department of Chemistry and Biology.
Read More: How to Extract Data From Table Based on Multiple Criteria in Excel
3. Applying FILTER Function to Extract Data Based on Criteria from Excel
You can also use the FILTER function to extract data based on criteria from Excel. Just follow the steps below.
Steps:
- At first, go to cell B19 and enter the following formula.
=FILTER(B5:E14,(D5:D14>=H4)*(D5:D14<=H5))
Here, D5:D14 represents the range of Marks of the students.
- Secondly, press the ENTER key.
4. Using Filter Option to Extract Data Based on Range Criteria from Excel
The Filter command in Excel is one of the most used and effective tools to extract specific data based on different criteria.
The steps to extract data based on a specific range using Excel’s Filter are given below.
Steps:
- First, select only the header of the dataset.
- Secondly, go to Data -> Filter.
- Third, it will insert a drop-down button in each header name of the dataset.
- Then, as we want to extract data based on the Marks, click on the drop-down button next to the Marks column.
- Next, from the drop-down list, select Number Filters -> Between… (again, as we are extracting data between 80 to 100, we select the option Between. You can select any other options from the list according to your criteria).
- Now, from the pop-up Custom AutoFilter box, select 80 from the drop-down list which will appear by simply clicking on the drop-down button next to is greater than or equal to label, and select 100 in the label box is less than or equal to.
- Later, click OK.
Finally, you will get all the details only for the students who got Marks from 80 to 100.
Read More: How to Extract Data from a List Using Excel Formula
5. Utilizing Advanced Filter to Extract Data from Excel Based on Range Criteria
If you don’t want to go through a lot of steps shown in the Filter section, you can use the Advanced Filter option in Excel to extract data based on a given range.
To utilize the advanced filter option in Excel, you have to define the condition in your worksheet to use later. See the following picture where we define our condition of extracting students’ details of Marks 80 to 100 in two different cells as >=80 and <=100 under Marks and we will be using the cell reference numbers of those cells later in our work.
The steps to extract data based on a particular range using Excel’s Advanced Filter are given below.
Steps:
- Firstly, select the whole data table.
- Second, go to Data -> Advanced.
- Finally, you will see the range of your selected data in the box next to the List range option.
- Then, in the box next to the Criteria range, select the cells carrying the defined conditions. You will see the name of the worksheet will be auto-generated there, following the cell reference numbers holding the predefined conditions.
- Lastly, click OK.
As a result, you will get all the details only for the students who got Marks from 80 to 100.
6. Extract Data from Excel Defined Table Based on Range Criteria
You can extract data from a defined table in Excel from your Excel worksheet using the Filter option. The steps to extract data from Excel defined table based on a certain range are given below.
Steps:
- Firstly, select any cell (we selected cell C6) from your dataset and press CTRL + T.
- Then, a pop-up Create Table Box will appear, showing the range of your dataset as values. Keep the check box My table has headers marked.
- Later, click OK.
Consequently, it will auto-generate a table based on your dataset with a drop-down button along with the headers.
- Then, follow the steps shown in the previous method to get the desired output.
At last, you will get an Excel-defined table carrying only the details of students’ who got Marks from 80 to 100.
Keep in Mind
- As the range of the data table array to search for the value is fixed, don’t forget to put the dollar ($) sign in front of the cell reference number of the array table.
- When working with array values, don’t forget to press CTRL + SHIFT + ENTER on your keyboard if you are working with any other version rather than Microsoft Excel 365.
- After pressing CTRL + SHIFT + ENTER, you will notice that the formula bar encloses the formula in curly braces {}, declaring it as an array formula. Don’t type those brackets {} yourself, Excel automatically does this for you.
Practice Section
For doing practice by yourself we have provided a Practice section like the one below in each sheet on the right side. Please do it by yourself.
Download Practice Workbook
You can download the free Excel practice workbook from here.
Conclusion
In this article, we have learned how to extract data from Excel based on different criteria. I hope that this article has been very beneficial to you. Feel free to ask any questions if you have regarding the topic.