How to Return TRUE If Cell Contains Text in Excel (8 Easy Ways)

Sometimes we need to determine whether a cell contains text or not. You’ll see this in the following example, where we use the ISTEXT function to return TRUE in cell C5 based on whether cell B5 contains text:

overview of Excel Return True If Cell Contains Text

In the below dataset, we have the product category of the vegetable cart. It also has some outliers set as numbers. For this dataset, we will determine which of them are text and return TRUE for any that are.

sample dataset containing the Category of the products


Method 1 – Use the ISTEXT Function to Directly Return TRUE If Cell Contains Text

Steps:

  • Select cell C5 and enter the following formula:

=ISTEXT(B5)

  • Press Enter.

Use ISTEXT Function to Return True If C5 Cell Contains Text

  • Drag the Fill Handle to cell C13.
  • You will notice that the range of cell C5:C13 returned TRUE or FALSE based on whether there is text in each cell in the range of cell B5:B13.

using autofill returns other results


Method 2 – Return TRUE for Text Through IF Function with Match Word

Steps:

  • Select cell C5 and enter the following formula:

=IF(B4="Bars","True","False")

  • Press Enter.

IF Function returns true for specific text

  • Drag the Fill Handle to cell C13.
  • You will notice that the range of cell C5:C13 returned TRUE or FALSE based on whether there is text in each cell in the range of cell B5:B13.

autofill returns IF function outputs for the below cells


Method 3 – Utilize ISNUMBER and SEARCH Functions to Return TRUE for Specific Text

Steps:

  • Select cell C5 and enter the following formula:

=ISNUMBER(SEARCH(B5,"Bars"))

  • Press Enter.

Utilize ISNUMBER and SEARCH Functions to return true if C5 cell contains specific text

Formula Breakdown

➢ SEARCH(B5,”Bars”): This part of the function will determine whether the text “Bars” is in cell B5 and return its position.

➢ =ISNUMBER(SEARCH(B5,”Bars”)): This part of the function will determine whether the return from the previous function is numerical or not. If it is numerical, then it will return TRUE, otherwise FALSE.

  • Drag the Fill Handle to cell C13.
  • You will notice that the range of cell C5:C13 returned TRUE or FALSE based on whether there is text in each cell in the range of cell B5:B13.

TRUE and FALSE is returned after using fill handle


Method 4 – Apply ISNUMBER and FIND Functions to Return True by Finding Text

Steps:

  • Select cell C5 and enter the following formula:

=ISNUMBER(FIND(B5,"Bars"))

  • Press Enter.

Apply ISNUMBER and FIND Functions to return true if cell contains particular text in Excel

Formula Breakdown

➢ FIND(B5,”Bars”): This part of the function will determine whether the text “Bars” is in cell B5 and return its position.

➢ ISNUMBER(FIND(B5,”Bars”)): This part of the function will determine whether the return from the previous function is numerical or not. If it jis numerical, then it will return  TRUE, otherwise FALSE.

  • Drag the Fill Handle to cell C13.
  • You will notice that the range of cell C5:C13 returned TRUE or FALSE based on whether there is text in each cell in the range of cell B5:B13.

TRUE and FALSE is returned after using autofill for ISNUMBER and FIND functions


Method 5 – Join IF, ISERRROR, and FIND Functions to Get TRUE for Text

Steps:

  • Select cell C5 and enter the following formula:

=IF(ISERROR(FIND("Bars",B5,1)),"False","TRUE")

  • Press Enter.

Join IF, ISERRROR, and FIND Functions to Get True for Text if C5 cell contains text in Excel

Formula Breakdown

➢ FIND(“Bars”,B5,1): This part of the function will determine whether the text “Bars” is in cell B5 and return its position of it.  1 represents as the starting position.

➢ ISERROR(FIND(“Bars”,B5,1)): This will determine whether the outcome from the previous function has an error or not

➢ IF(ISERROR(FIND(“Bars”,B5,1)),”False”,”TRUE”): This part of the function will determine whether the return from the previous function has any error or not. If it is an error, then it will return  FALSE. Otherwise, it will return TRUE.

  • Drag the Fill Handle to cell C13.
  • You will notice that the range of cell C5:C13 returned TRUE or FALSE based on whether there is text in each cell in the range of cell B5:B13.

autofil returns TRUE and FALSE for IF, ISERROR, and FIND functions


Method 6 – Combine IF and COUNTIF Functions to Return True by Condition

Steps:

  • Select cell C5 and enter the following formula:

=IF(COUNTIF(B5,"*"&"Bars"&"*"),"True","False")

  • Press Enter.

Combine IF and COUNTIF Functions in Excel to return true if C5 cell contains specific text

Formula Breakdown

➢ COUNTIF(B5,”*”&”Bars”&”*”):  This part of this function will count the characters in the B5 cell to see if they’re equal to Bars.

➢ IF(COUNTIF(B5,”*”&”Bars”&”*”),”True”,”False”) This part of the function will determine whether the return from the previous function has any number or not. If it is a number, then it will return TRUE FALSE, otherwise, will return FALSE.

  • Drag the Fill Handle to cell C13.
  • You will notice that the range of cell C5:C13 returned TRUE or FALSE based on whether there is text in each cell in the range of cell B5:B13.

TRUE and false is returned for IF and COUNTIF functions after using autofill


Method 7 – Apply IF and EXACT Functions by Matching Word Precisely

Steps:

  • Select cell C5 and enter the following formula:

=IF(EXACT(B5,"Bars"), "True", "False")

  • Press Enter.

Apply IF and EXACT Functions to return true if cell contains particular text in Excel

Formula Breakdown

➢ EXACT(B5,”Bars”):  This part of this function will determine the cell value in cell B5 to see if it is Bars or not. If they are the same, then it will return TRUE, otherwise FALSE.

➢ IF(EXACT(B5,”Bars”), “True”, “False”): This part will return TRUE if the return from the previous function is TRUE, otherwise it will return FALSE.

  • Drag the Fill Handle to cell C13.
  • You will notice that the range of cell C5:C13 returned TRUE or FALSE based on whether there is text in each cell in the range of cell B5:B13.

TRUE and false is returned for IF and EXACT functions after using autofill


Method 8 – Embed VBA to Return TRUE If Cell Contains Exact Text

Steps:

  • We have the text value in cell B5, we need to determine whether this cell actually contains text or not and then return Yes or No based on the inspection.

dataset for applying vba method

  • Go to the Developer tab and click on Visual Basic. You can also press ‘Alt+F11’for open the Visual Basic Editor.

select visual basic from developer tab

  • In the new dialog box, click on Insert > Module.
  • Type the following code in the Module editor window:
Sub Contains_text()
    If InStr(Range("B5").Value, "Bars") > 0 Then
    Range("C5").Value = "True"
    End If
End Sub

type code in module box

  • Close the Module window.
  • Go to the View tab > Macros.
  • Click on View Macros.

run the macro using view macros command

  • After clicking View Macros, select the macros that you created. The file name here is Contains_text.
  • Click Run.

select macro in the Macro dialog box and run it

  • Cell C5 should now show TRUE, as cell B5 has text.

output of macro code returns true


Download Practice Workbook


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

Get FREE Advanced Excel Exercises with Solutions!
Rubayed Razib Suprov
Rubayed Razib Suprov

Rubayed Razib, holding a BSC degree in Naval Architecture & Engineering from Bangladesh University of Engineering and Technology, serves as a devoted member of the ExcelDemy project. He has contributed significantly by authoring numerous articles and showcasing proficiency in VBA. Razib efficiently automates Excel challenges using VBA macros and actively participates in the ExcelDemy forum, providing valuable solutions for user interface challenges. Apart from creating Excel tutorials, he is interested in Data Analysis with MS Excel,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo