How to Filter Data Based on Cell Value in Excel (4 Easy Methods)

The following GIF shows the filtered rows based on the device name from the drop-down selection, which we’ll create.

1-How to Filter Data Based on Cell Value in Excel


Method 1 – Apply Keyboard Shortcuts to Filter Data Based on Cell Value

Our dataset contains PC brands, device types, model names, origins, release dates, and corresponding prices.

2-Dataset to filter based on cell value

  • Select a cell for which value you want to filter your dataset. We’ll filter for the origin country being USA.
  • Press and hold the Menu key on your keyboard and press E + V.

3-Applying keyboard shortcut to filter data based on cell value

  • The Filter command will be activated and it will show the filtered rows based on your selection.

Method 2 – Filter Data Based on Cell Value by Using the Filter Command

  • Select any cell of your dataset.
  • Go to Home then to Editing.
  • Choose Sort & Filter and pick Filter.

5-Applying Filter command to filter data based on cell value

  • The Sort & Filter icon will be visible in every header of your dataset.
  • Click on the Sort & Filter icon of the Origin header and mark USA from the list.

6-Filtering data for USA region

  • Here’s the filtered result.

7-Filtered data for USA region


Method 3 – Apply the FILTER Function to Filter Data Based on Cell Value


Example 1 – Filter for a Range

We’ll filter the data based on a price range of $700 to $1,000.

8-Dataset to apply FILTER function to filter data based on a range of price

  • Insert the following formula in cell B22 and hit the Enter button:
=FILTER(B6:G16, (G6:G16 >C18 )*(G6:G16<C19))

9-Applying FILTER function to filter data based on a range of price

  • If you change the values, it will instantly update the filter result as shown below.

10-GIF file of Applying the FILTER function to filter data based on a range of price


Example 2 – Filter for Specific Text

Let’s filter the data for model names that contain the term ocd.

  • Apply the following formula in cell B21 and press the Enter button:
=IFERROR(FILTER(B6:G16,ISNUMBER(SEARCH(C18,D6:D16))),"")

11-Applying IFERROR, ISNUMBER, SEARCH, and FILTER functions to filter data for specific text

  • Whenever you type a text partially, it will return the matched result.

12-GIF file of applying IFERROR, ISNUMBER, SEARCH, and FILTER functions to filter data for specific text

  • The IFERROR function avoids the #CALC! error and will return a blank.

13-Using IFERROR function to avoid error while filtering for specific text


Example 3 – Filter Data Based on Date

  • Use the following formula in cell B21 to filter the data for the date 19-May-21:
=FILTER(B6:G16,F6:F16=C18,"No data")

14-Applying FILTER function to filter for a specific date

  • If the date doesn’t match with any date of our dataset, the function will return No Data.

15-FILTER function returning ‘No Data’ while getting no match with the date


Example 4 – A Dynamic Filter with a Drop-Down List

  • Insert the following formula in cell B21 to filter the data by Desktop, which is in cell C18.
=FILTER(B6:G16,ISNUMBER(SEARCH(C18,C6:C16)))

16-Applying ISNUMBER, SEARCH, and FILTER functions to filter data for an exact match

17-Inserting a drop-down list to filter data dynamically for an exact match


Example 5 – Filter Out Rows with Blank Cells

We modified the dataset by keeping some blank cells in some rows.

18-Dataset with some blank cells in different rows

  • Insert the following formula in cell B19 and press Enter to filter out the rows with blank cells:
=FILTER(B6:G16,(C6:C16<>"")*(D6:D16<>""),"No Result")

19-Applying FILTER function to filter out rows with blank cells


Example 6 – Filter for Case-Sensitive Values

In the Origin column, there are two types of cases for the same origin, “USA” and “usa”.

20-Dataset with some case-sensitive values in a column

  • Apply the following formula in cell B21 to filter the data for lowercase “usa”:
=FILTER(B6:G16,EXACT(E6:E16,C18))

21-Applying EXACT and FILTER functions to filter for case-sensitive match

  • Here’s the result.

22-GIF file of the case-sensitive filter operation


Method 4 – VBA Code to Filter Data Based on Cell Value


Case 1 – Filter for Top N Values

We’ll filter the data for top N values from the Price column.

  • Insert the following code in a new Module:
Sub Filter_for_top_N()
Dim TopN As Variant
TopN = InputBox("Insert the value of N", "Filter for Top N Values")
ActiveSheet.Range("B5:G16").AutoFilter Field:=6, Criteria1:=TopN, Operator:=xlTop10Items
End Sub
  • Run the code by clicking on the Run icon or by pressing F5.

23-VBA code to filter top N values of a column

  • An input box will open up to insert the value of N. We inserted 3.

24-Inseting the value of N to filter data

  • The dataset will be filtered based on the top 3 values of the Price column.

25-Top 3 filtered price after applying VBA


Case 2 – Filter with a Drop-Down List

We’ll create the drop-down list in cell B19.

26-Dataset to filter with a drop-down list

  • Right-click on the sheet name.
  • Select View Code from the context menu.

27-Opening Sheet in VBA to insert code

  • Put in the following code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("B19").Address Then
Range("B5:G16").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("B18:B19")
End If
End Sub

28-Inserting VBA code to filter for an exact match

  • If we change the value in cell B19, the VBA code will automatically filter the data range according to that value.

29-Filtered result after applying VBA code

  • We added a drop-down list in cell B19 for easy selection.

30-Adding drop-down list after applying VBA code


Download the Practice Workbook


<< Go Back to Data | Filter in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Md. Abdullah Al Murad
Md. Abdullah Al Murad

Md. Abdullah Al Murad is a computer engineer who loves exploring Excel and VBA programming. Programming, to him, is a time-saving tool for efficiently managing data, files, and internet tasks. He is proficient in C, C++, Python, JavaScript, HTML, SQL, MySQL, PostgreSQL, Microsoft Office, and VBA and goes beyond the basics. He holds a B.Sc. in Computer Science and Engineering from American International University-Bangladesh. He has transitioned into the role of a content developer. Beyond his work, find... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo