How to Check If Cell Contains Text Then Return Value in Excel

We have entries of certain Categories and Products in a dataset. We’ll check if a cell contains text and then return a value in Excel.

Dataset for Checking If Cell Contains Text Then Return Value in Excel


Method 1 – Use the IF Function to Check If Cell Contains Text, Then Return a Value

The syntax of the IF function is:

=IF (logical_test,[value_if_true],[value_if_false])

Steps:

  • Select Cell D5 and insert the following formula.
=IF(B5="Bars","Available","Not Available")
  • Press Enter and drag the Fill Handle down to copy the formula for the rest of the cells.

Using IF Function to Check If Cell Contains Text Then Return Value in Excel

  • Available or Not Available values will appear throughout the range.

Values Found After Checking Cells Contains Text Using IF Function

Here, the logical_test is to match Bars text in cell B5; if the test is TRUE it results in Available, otherwise Not Available.

Method 2 – Use the IF and ISTEXT Functions to Check If Cell Contains Text, Then Return Value

Steps:

  • Insert the following formula in Cell D5 and press Enter.
=IF(ISTEXT(B5),B5,"")
  • Drag down the Fill Handle tool to AutoFill the formula for the rest of the cells.

Utilizing IF & ISTEXT Functions to Check If Cell Contains Text Then Return Value in Excel

  • The formula will return only the text values.

Values Found After Checking If Cells Contains Text Utilizing IF & ISTEXT Functions

How Does the Formula Work?

  • We used the ISTEXT function to check if Cell B5 contains text.
  • We used the IF function to return the value of Cell B5 if the result of the ISTEXT function is TRUE. Otherwise, we return a Blank.

Method 3 – Apply ISNUMBER and SEARCH Functions to Find If a Cell Contains Text

Steps:

  • Click on Cell D5 and insert the following formula.
=ISNUMBER(SEARCH("Bars",$B$5:$B$13))

Applying ISNUMBER & SEARCH Functions to Find If Cell Contains Text Then Return Value in Excel

  • Press Enter.

Values Found After Checking If Cells Contains Text Applying ISNUMBER & SEARCH Functions

The SEARCH function matches the text “Bars” in an absolute range and then returns True or False depending on the match.

Method 4 – Check If Cell Contains Text, Then Return Value in Excel Using IF and EXACT Functions

This formula works for a case-sensitive match.

Steps:

  • SWelect Cell D5 and paste the following formula.
=IF(EXACT(B5,"Bars"),"Available","")
  • Hit Enter.
  • Drag the Fill Handle to copy the formula.

Check If Cell Contains Text Then Return Value in Excel Using IF & EXACT Functions

  • Here are the results.

Values Found After Checking Cells Contains Text Using IF & EXACT Functions

The EXACT function matches the exact text “Bars” in cell B5 then returns the value “Available” otherwise BLANK the cell depending on an exact match.

Method 5 – Combine IF and COUNTIF Functions to Check If a Cell Contains Text

Steps:

  • Insert the following formula in Cell D5 and press Enter.
=IF(COUNTIF(B5,"*Bars*"),B5,"")
  • Drag down the Fill Handle tool to AutoFill the formula for the rest of the cells.

Combining IF & COUNTIF Functions to Check If Cell Contains Text Then Return Value in Excel

  • Matching cells will show the same values as the range.

Values Found After Checking Cells Contains Text Using IF & COUNTIF Functions

In the formula, the COUNTIF function matches the criteria “*Bars*” (the formula automatically puts * both sides of the criteria) in range (cell B5). Then it returns the value in B5 otherwise keeps the cell Blank.

Method 6 – Use INDEX and MATCH Functions to Find If Cell Contains Text, Then Return a Value in Excel

Steps:

  • Insert the following formula in Cell C15.
=INDEX(C5:C13,MATCH("Bars",B5:B13,0))
  • Press Enter if you’re using Excel 365, or press Ctrl + Shift + Enter.
  • The matched text for Bars will appear.

Using INDEX and MATCH Functions to Find If Cell Contains Text Then Return Value in Excel

The INDEX function looks for the exact match text “Bars” from the range B5:B13 in the range C5:C13.

Method 7 – Apply the VLOOKUP Function to Check If a Cell Contains Text in Excel

Steps:

  • Insert the lookup text (Bars) in any cell (B16).

Applying VLOOKUP Function to Check If Cell Contains Text in Excel

  • Select Cell C16 and insert the following formula.
=VLOOKUP(B16,B5:C13,2,FALSE)
  • Press Enter and the matched value will appear.

Values Found After Checking Cells Contains Text Using VLOOKUP Function

Here “Bars” is the text in B3 that has to match within a range B7:C15 to a value in column 2. FALSE declares we want an exact match.

Method 8 – Use Combined Functions to Check if a Cell Contains Text with OR Conditions

Steps:

  • Insert the following formula in Cell D5 and press Enter.
=IF(OR(ISNUMBER(SEARCH("Bars",B5)),ISNUMBER(SEARCH("Veg",B5))),"Available","")
  • Drag down the Fill Handle tool to AutoFill the formula for the rest of the cells.

Using Combined Functions to Check if Cell Contains Text with OR Condition in Excel

  • Here’s the result.

Values Found After Checking Cells Contains Text Using Combined Functions with OR Condition

How Does the Formula Work?

  • We used the SEARCH function to find cell range Bars in Cell B5.
  • We used the ISNUMBER function to check if the result of the SEARCH function is a number.
  • We searched for Veg in Cell B5 using these two functions.
  • We used the OR function to check if any of these two texts (Bars or Veg) is present in Cell B5.
  • We used the IF function to return Available if True or leave the cell blank otherwise.

Method 9 – Check If a Cell Contains Text with an AND Condition by Applying Combined Functions

Steps:

  • Select Cell D5 and insert the following formula.
=IF(AND(ISNUMBER(SEARCH("Bars",B5)),ISNUMBER(SEARCH("Chlt",B5))),"Available ","")
  • Press Enter. If both of the text strings exist in cell B5, the formula returns “Available” as a value. Otherwise, the cell remain BLANK.
  • Drag the Fill Handle to copy the formula for the rest of the cells.

Checking If Cell Contains Text with AND Condition Applying Combined Functions in Excel

  • Here are the results.

Values Found After Checking Cells Contains Text Using Combined Functions with AND Condition

How Does the Formula Work?

  • We used the SEARCH and ISNUMBER functions like Method 8.
  • We used the AND function to check if these two texts (Bars and Veg) are present in Cell B5.
  • We used IF function to return Available if True, otherwise Blank.

Practice Section

We attached a practice dataset that you can use to test these methods.

Practice Section to Check Cell Contains Text Value Then Return Value in Excel


Download the Practice Workbook


<< Go Back to Text | If Cell Contains | Formula List | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Maruf Islam
Maruf Islam

MARUF ISLAM is an excellent marine engineer who loves working with Excel and diving into VBA programming. For him, programming is like a superhero tool that saves time when dealing with data, files, and the internet. His skills go beyond the basics, including ABACUS, AutoCAD, Rhinoceros, Maxsurf, and Hydromax. He got his B.Sc in Naval Architecture & Marine Engineering from BUET, and now he's switched gears, working as a content developer. In this role, he creates techy content... Read Full Bio

6 Comments
  1. Reply
    Dr. Linda Vandergriff Sep 29, 2022 at 2:08 AM

    If some idiot changes the dollar value by putting a text character in it, how do I get just the value? Not of these methods seem to help.

    Cell = ‘50.50 I want to get the value Cell 2 = 50.50 Where is this covered?

    • Greetings Dr. Linda Vandergriff,

      Go through the following methods to get rid of the inconvenience. Make sure the value cells are in the Currency or Accounting Number Format.

      1. Manually delete the preceding Apostrophes. Or

      2. Use a formula to auto remove the Apostrophes as shown in the image.

      =NUMBERVALUE(SUBSTITUTE(B2,"'",""))

      Formula

      Feel free to comment if you have further inquiries. We are here to help.

      Regards
      Maruf Islam (Exceldemy Team)

  2. HI, I want to pull text from multiple sheets and ignore some specific text as blank or space. How to do it?

    Example .
    If sheet 1 has John in B2 and sheet2 has Jacob in B2 and i want an output in sheet3, where if sheet 2 has Jacob then ignore or blank.
    =Sheet1!B2&” “&Sheet2!B2

    • Hi Mohammed Shahid,
      You can pull text from multiple sheets and ignore blank or space by using the TRIM function. This function will help you to remove space automatically.
      To solve your problem, use the following formula in Cell B2 of Sheet 3 in your Excel worksheet.
      =TRIM(Sheet1!B2&" "&Sheet2!B2)

      Pulling Text from Multiple Sheets and Removing Blank or Space

      Hope this will solve your problem. Feel free to comment if you have further inquiries.
      Regards,
      Arin Islam.

  3. Reply
    James Kaj Tulloch Feb 10, 2024 at 12:13 AM

    Hello, is it possible to somehow combine the EXACT and IF & ISTEXT Functions to return the text value of two cells in different columns instead of TRUE/FALSE? I am trying to match answers to two slightly different questions in a survey which have the same list of potential answers.

    • Reply Lutfor Rahman Shimanto
      Lutfor Rahman Shimanto Feb 11, 2024 at 11:33 AM

      Hello JAMES

      Thanks for reaching out and sharing your queries. To return the text value of two cells in different columns if they match, you can combine the EXACT, IF and ISTEXT functions.

      Excel Formula: =IF(AND(ISTEXT(A2), ISTEXT(B2), EXACT(A2, B2)), A2:B2, "No Match")

      So, in simpler terms, the formula checks if both cells A2 and B2 contain text and if the text in both cells is the same. If they are, it returns the values from cells A2 and B2 together. If not, it returns “No Match”.

      OUTPUT:

      Hopefully, the idea will help you; good luck.

      Regards
      Lutfor Rahman Shimanto
      ExcelDemy

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo