How to Check If Value Exists in Range in Excel (8 Ways)

We have the Product List and the Order List of the products of a company, and we want to check if the products of the Order List are available in the Product List.

Excel check if value exists in range


Method 1 – Using the COUNTIF Function to Check If a Value Exists in a Range

We will get the results as TRUE or FALSE in the Status column.

Excel check if value exists in range

Steps:

  • Use the following formula in cell F4
=COUNTIF($B$4:$B$10,E4)>0

COUNTIF Function

  • Press Enter and drag down the Fill Handle tool.

COUNTIF Function

  • Here are the results.

Excel check if value exists in range


Method 2 – Using IF and COUNTIF Functions to Check If a Value Exists in a Range

We’ll use the same dataset. We’ll return custom texts as results.

Excel check if value exists in range

Steps:

Use the following formula in cell F4

=IF(COUNTIF($B$4:$B$10,E4)>0,"Exist","Does not Exist")

For the result TRUE, we will get Exist and for FALSE we will get Does not Exist.

IF and COUNTIF Function

  • Press Enter and drag down the Fill Handle tool.

IF and COUNTIF Function

Here are the results.

Excel check if value exists in range


Method 3 – Checking a Partial Match of Values in a Range

We will check the partial match of the products. We’ve modified the dataset a bit.

Excel check if value exists in range

Steps:

  • Use the following formula in cell F4
=COUNTIF($B$4:$B$10,"*"&E4&"*")>0

Adding the Asterisk symbol before and after the value of cell E4 will account for zero or more other characters around it.

partial match

  • Press Enter and drag down the Fill Handle tool.

partial match

  • Here are the results.

Excel check if value exists in range


Method 4 – Using ISNUMBER and MATCH Functions to Check If a Value Exists in a Range

We’ll use the same dataset.

Excel check if value exists in range

Steps:

  • Use the following formula in cell F4
=ISNUMBER(MATCH(E4,$B$4:$B$10,0))
  • MATCH(E4,$B$4:$B$10,0) → returns the row index number of the value Green Apple in cell E4 in the range $B$4:$B$10, otherwise #N/A error for not matching the values
    Output → #N/A
  • ISNUMBER(MATCH(E4,$B$4:$B$10,0)) becomes
    ISNUMBER(#N/A) → returns TRUE for any number values otherwise FALSE
    Output → FALSE

ISNUMBER & MATCH Function

  • Press Enter and drag down the Fill Handle tool.

ISNUMBER & MATCH Function

  • Here are the results.

ISNUMBER & MATCH Function

Read More: How to Use Excel IF Function with Range of Values


Method 5 – Check If a Value Exists in a Range Using IF, ISNA, and VLOOKUP Functions

We’ll use the same dataset.

Excel check if value exists in range

Steps:

  • Use the following formula in cell F4
=IF(ISNA(VLOOKUP(E4,$B$4:$B$10,1,FALSE)),"Does Not Exist","Exists")
  • VLOOKUP(E4,$B$4:$B$10,1, FALSE) → finds the exact match of the product Green Apple in the range $B$4:$B$10 and extracts this value from this column and for not finding the value in the range returns #N/A.
    Output → #N/A
  • ISNA(VLOOKUP(E4,$B$4:$B$10,1,FALSE)) becomes
    ISNA(#N/A) → returns TRUE if there is a #N/A error otherwise FALSE
    Output → TRUE
  • IF(ISNA(VLOOKUP(E4,$B$4:$B$10,1,FALSE)),”Does Not Exist”,”Exists”) becomes
    IF(TRUE, “Does Not Exist”, “Exists”) → returns Does Not Exist for TRUE and Exists for FALSE
    Output → Does Not Exist

IF, ISNA & VLOOKUP Function

  • Press Enter and drag down the Fill Handle tool.

IF, ISNA & VLOOKUP Function

  • Here are the results.

Excel check if value exists in range


Method 6 – Using IF, ISNA, and MATCH Functions to Check If a Value Exists in a Range

We’ll use the same dataset.

Excel check if value exists in range

Steps:

  • Use the following formula in cell F4
=IF(ISNA(MATCH(E4,$B$4:$B$10,0)),"Does Not Exist","Exists")
  • MATCH(E4,$B$4:$B$10,0) finds the exact match of the product Green Apple in the range $B$4:$B$10 and gives the row index number of this product in the range $B$4:$B$10 and for not finding the value in the range returns #N/A.
    Output → #N/A
  • ISNA(MATCH(E4,$B$4:$B$10,0)) becomes
    ISNA(#N/A) → returns TRUE if there is a #N/A error otherwise FALSE
    Output → TRUE
  • IF(ISNA(MATCH(E4,$B$4:$B$10,0)),”Does Not Exist”,”Exists”)becomes
    IF(TRUE, “Does Not Exist”, “Exists”) → returns Does Not Exist for TRUE and Exists for FALSE
    Output → Does Not Exist

IF, ISNA & MATCH Function

  • Press Enter and drag down the Fill Handle tool.

IF, ISNA & MATCH Function

  • Here’s the result.

IF, ISNA & MATCH Function


Method 7 – Conditional Formatting to Check If Value Exists in Range

We will highlight the products in the Order List column if they are available in the Product List column.

Excel check if value exists in range

Steps:

  • Select the cell range on which you want to apply the Conditional Formatting (We have selected the column Order List).
  • Go to the Home tab, choose Conditional Formatting, and select New Rule.

Conditional Formatting

  • The New Formatting Rule wizard will appear.
  • Select Use a formula to determine which cells to format, and click the Format option.

Conditional Formatting

  • The Format Cells dialog will open.
  • Select the Fill tab.
  • Choose any Background Color and click on OK.

Excel check if value exists in range

  • The Preview will be shown as below.

Conditional Formatting

  • Use the following formula in the Format values where this formula is true box:
=MATCH(E4,$B$4:$B$10,0)
  • Press OK.

Conditional Formatting

  • This highlights all the cells that fill the formula’s criteria.

Excel check if value exists in range

Read More: How to Use IF Function with Multiple Conditions in Excel


Method 8 – Using VBA Code to Check If a Value Exists in a Range in Excel

We’ll use the same starting dataset.

Excel check if value exists in range

Steps:

  • Go to the Developer tab and select Visual Basic.

VBA Code

  • The Visual Basic Editor will open.
  • Go to the Insert tab and select Module.

VBA Code

  • A Module will be created.

VBA Code

  • Insert the following code in the module:
Sub checkvalue()

Dim X As Variant
Dim Rng As Range

For i = 4 To 8
X = Cells(i, 5)
With Sheets("VBA").Range("B4:B10")
Set Rng = .Find(What:=X, After:=.Cells(.Cells.Count), _
LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not Rng Is Nothing Then
Cells(i, 6).Value = "Exists"
Else
Cells(i, 6).Value = "Does not exist"
End If
End With
Next i

End Sub

We have declared X as Variant, Rng as Range, and here, VBA is the sheet name.

The FOR loop will execute the operations for each row of the column Order List from Row 4 to Row8, Range(“B4:B10”) is the range of the Product List column. X is assigned to the values of each cell of the Order List column and after finding the matching by using the FIND function we will get Exists in the adjacent cell of the corresponding cell of this column. For not finding the value it will return Does not exist.

VBA Code

  • Press F5.

Excel check if value exists in range


Practice Section

We have provided a Practice section like below in a sheet named Practice.

Practice


Download the Practice Workbook


Related Articles


<< Go Back to Excel IF Function | Excel Functions | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Tanjima Hossain
Tanjima Hossain

TANJIMA HOSSAIN is a marine engineer who enjoys working with Excel and VBA programming. For her, programming is a handy, time-saving tool for managing data, files, and online tasks. She's skilled in Rhino3D, Maxsurf C++, MS Office, AutoCAD, and Excel & VBA, going beyond the basics. She holds a B.Sc. in Naval Architecture & Marine Engineering from BUET and is now a content developer. In this role, she creates tech-focused content centred around Excel and VBA. Apart from... Read Full Bio

2 Comments
  1. I have two columns in one table – either column could contain a match with a range on another table… how can I write a formula that checks for a match first in one of the columns, and if there is a match it returns that value, and if there is no match, it checks the other column for a match, and returns that value. If no matches in either column, then “no match”. Help?

    • Hello JORDAN,

      Hope you are doing well! As per your requirement, I am considering the following scenario where in a table I have two lists of products with which I will compare the products in the Order List column. I will use a formula that will match a product from the Order List column with products from the Product List 1 column, for matches, the name of the product will return. Otherwise, the formula will search for matches in the Product List 2 column and will return the product name if any matches are found. Otherwise, we will get “No Match”.

      1

      • Enter the following formula in cell F4.
      =IF (COUNTIF ($B$4: $B$10, E4)>0, E4, IF (COUNTIF ($C$4: $C$10, E4)>0, E4, "No Match"))
      • Drag down the Fill Handle tool.

      2

      Finally, we are having Green Apple and Kiwi as they appear in the Product List 2 column, and Banana as it appears in the Product List 1 column.

      3

      Best Regards,
      Tanjima Hossain
      ExcelDemy

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo