Excel for Microsoft 365 Excel 2021 Excel 2019 Excel 2016 Excel 2013 Excel 2010 Excel 2007 More…Less
Let’s say you want to ensure that a column contains text, not numbers. Or, perhapsyou want to find all orders that correspond to a specific salesperson. If you have no concern for upper- or lowercase text, there are several ways to check if a cell contains text.
You can also use a filter to find text. For more information, see Filter data.
Find cells that contain text
Follow these steps to locate cells containing specific text:
-
Select the range of cells that you want to search.
To search the entire worksheet, click any cell.
-
On the Home tab, in the Editing group, click Find & Select, and then click Find.
-
In the Find what box, enter the text—or numbers—that you need to find. Or, choose a recent search from the Find what drop-down box.
Note: You can use wildcard characters in your search criteria.
-
To specify a format for your search, click Format and make your selections in the Find Format popup window.
-
Click Options to further define your search. For example, you can search for all of the cells that contain the same kind of data, such as formulas.
In the Within box, you can select Sheet or Workbook to search a worksheet or an entire workbook.
-
Click Find All or Find Next.
Find All lists every occurrence of the item that you need to find, and allows you to make a cell active by selecting a specific occurrence. You can sort the results of a Find All search by clicking a header.
Note: To cancel a search in progress, press ESC.
Check if a cell has any text in it
To do this task, use the ISTEXT function.
Check if a cell matches specific text
Use the IF function to return results for the condition that you specify.
Check if part of a cell matches specific text
To do this task, use the IF, SEARCH, and ISNUMBER functions.
Note: The SEARCH function is case-insensitive.
Need more help?
Return to Excel Formulas List
Download Example Workbook
Download the example workbook
This tutorial will demonstrate how to check if any cell in a range contains any text in Excel and Google Sheets.
Check if Range Contains Any Text
To test if any cell in a range contains any text, we will use the ISTEXT and SUMPRODUCT Functions.
ISTEXT Function
The ISTEXT Function does exactly what its name implies. It tests if a cell is text, outputting TRUE or FALSE.
=ISTEXT(A2)
SUMPRODUCT Function
The ISTEXT Function only tests a single cell, so we must find a way to test the entire range. This is where the SUMPRODUCT Function comes in. The SUMPRODUCT Function sums together arrays of values. So if we test each cell individually, outputting a 1 (TRUE) or 0 (FALSE) if each cell as text, then we can sum the values together. If the sum is greater than 0 than we know at least one cell contained text.
First, here is the final calculation:
=SUMPRODUCT(--ISTEXT(A2:C2))>0
Now let’s walk through it.
=SUMPRODUCT(--ISTEXT(A2:C2))>0
=SUMPRODUCT(--{FALSE TRUE, TRUE})>0
=SUMPRODUCT({0, 1, 1})>0
=2>0
=TRUE
Note: the double negatives converts the TRUE/FALSE into 1 / 0. Alternatively you could multiply the ISTEXT Function by *1
=SUMPRODUCT(ISTEXT(A2:C2)*1)>0
Instead of outputting TRUE / FALSE, you can use an IF Statement to output other text or calculations:
=IF(SUMPRODUCT(--ISTEXT(A2:C2))>0, "Yes", "No")
Google Sheets – Check if any Cell in a Range Contains Text
All of the above examples work exactly the same in Google Sheets as in Excel.
Содержание
- Check if a cell contains text (case-insensitive)
- Find cells that contain text
- Check if a cell has any text in it
- Check if a cell matches specific text
- Check if part of a cell matches specific text
- Check if any Cell in a Range Contains Text – Excel & Google Sheets
- Check if Range Contains Any Text
- ISTEXT Function
- SUMPRODUCT Function
- Google Sheets – Check if any Cell in a Range Contains Text
- If cell contains
- Related functions
- Summary
- Generic formula
- Explanation
- Dave Bruns
- Excel If Cell Contains Text
- If Cell Contains Text
- If Cell Contains Text Then TRUE
- If Cell Contains Partial Text
- Find for Case Sensitive Match:
- Search for Not Case Sensitive Match:
- If Range of Cells Contains Text
- If Cells Contains Text From List
- If Cell Contains Text Then Return a Value
- Excel if cell contains word then assign value
- Count If Cell Contains Text
- Count If Cell Contains Partial Text
- If Cell contains text from list then return value
- If Cell Contains Text Then SUM
- Sum If Cell Contains Partial Text
- VBA to check if Cell Contains Text
- If Cell Contains Partial Text VBA
- If Cell Contains Text Then VBA MsgBox
- Which function returns true if cell a1 contains text?
- Which function returns true if cell a1 contains text value?
Check if a cell contains text (case-insensitive)
Let’s say you want to ensure that a column contains text, not numbers. Or, perhapsyou want to find all orders that correspond to a specific salesperson. If you have no concern for upper- or lowercase text, there are several ways to check if a cell contains text.
You can also use a filter to find text. For more information, see Filter data.
Find cells that contain text
Follow these steps to locate cells containing specific text:
Select the range of cells that you want to search.
To search the entire worksheet, click any cell.
On the Home tab, in the Editing group, click Find & Select, and then click Find.
In the Find what box, enter the text—or numbers—that you need to find. Or, choose a recent search from the Find what drop-down box.
Note: You can use wildcard characters in your search criteria.
To specify a format for your search, click Format and make your selections in the Find Format popup window.
Click Options to further define your search. For example, you can search for all of the cells that contain the same kind of data, such as formulas.
In the Within box, you can select Sheet or Workbook to search a worksheet or an entire workbook.
Click Find All or Find Next.
Find All lists every occurrence of the item that you need to find, and allows you to make a cell active by selecting a specific occurrence. You can sort the results of a Find All search by clicking a header.
Note: To cancel a search in progress, press ESC.
Check if a cell has any text in it
To do this task, use the ISTEXT function.
Check if a cell matches specific text
Use the IF function to return results for the condition that you specify.
Check if part of a cell matches specific text
To do this task, use the IF, SEARCH, and ISNUMBER functions.
Note: The SEARCH function is case-insensitive.
Источник
Check if any Cell in a Range Contains Text – Excel & Google Sheets
Download the example workbook
This tutorial will demonstrate how to check if any cell in a range contains any text in Excel and Google Sheets.
Check if Range Contains Any Text
To test if any cell in a range contains any text, we will use the ISTEXT and SUMPRODUCT Functions.
ISTEXT Function
The ISTEXT Function does exactly what its name implies. It tests if a cell is text, outputting TRUE or FALSE.
SUMPRODUCT Function
The ISTEXT Function only tests a single cell, so we must find a way to test the entire range. This is where the SUMPRODUCT Function comes in. The SUMPRODUCT Function sums together arrays of values. So if we test each cell individually, outputting a 1 (TRUE) or 0 (FALSE) if each cell as text, then we can sum the values together. If the sum is greater than 0 than we know at least one cell contained text.
First, here is the final calculation:
Now let’s walk through it.
Note: the double negatives converts the TRUE/FALSE into 1 / 0. Alternatively you could multiply the ISTEXT Function by *1
Instead of outputting TRUE / FALSE, you can use an IF Statement to output other text or calculations:
Google Sheets – Check if any Cell in a Range Contains Text
All of the above examples work exactly the same in Google Sheets as in Excel.
Источник
If cell contains
Summary
To test for cells that contain certain text, you can use a formula that uses the IF function together with the SEARCH and ISNUMBER functions. In the example shown, the formula in C5 is:
Generic formula
Explanation
One limitation of the IF function is that it does not support wildcards like «?» and «*». This means you can’t use IF by itself to test for text that may appear anywhere in a cell.
One solution is a formula that uses the IF function together with the SEARCH and ISNUMBER functions. In the example shown, we have a list of email addresses, and we want to extract those that contain «abc». In C5, the formula were using is this:
If «abc» is found anywhere in cell B5, IF will return that value. If not, IF will return an empty string («»). In this formula, the logical test is this bit:
This snippet will return TRUE if the the value in B5 contains «abc» and false if not. The logic of ISNUMBER + SEARCH is explained in detail here.
To copy cell the value in B5 when it contains «abc», we provide B5 again for the «value if true» argument. If FALSE, we supply an empty string («») which will display as a blank cell on the worksheet.
Dave Bruns
Hi — I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.
Источник
Excel If Cell Contains Text
Excel If Cell Contains Text Then Formula helps you to return the output when a cell have any text or a specific text. You can check if a cell contains a some string or text and produce something in other cell. For Example you can check if a cell A1 contains text ‘example text’ and print Yes or No in Cell B1. Following are the example Formulas to check if Cell contains text then return some thing in a Cell.
If Cell Contains Text
Here are the Excel formulas to check if Cell contains specific text then return something. This will return if there is any string or any text in given Cell. We can use this simple approach to check if a cell contains text, specific text, string, any text using Excel If formula. We can use equals to operator(=) to compare the strings .
If Cell Contains Text Then TRUE
Following is the Excel formula to return True if a Cell contains Specif Text. You can check a cell if there is given string in the Cell and return True or False.
The formula will return true if it found the match, returns False of no match found.
If Cell Contains Partial Text
We can return Text If Cell Contains Partial Text. We use formula or VBA to Check Partial Text in a Cell.
Find for Case Sensitive Match:
We can check if a Cell Contains Partial Text then return something using Excel Formula. Following is a simple example to find the partial text in a given Cell. We can use if your want to make the criteria case sensitive.
- Here, Find Function returns the finding position of the given string
- Use Find function is Case Sensitive
- IsError Function check if Find Function returns Error, that means, string not found
Search for Not Case Sensitive Match:
We can use Search function to check if Cell Contains Partial Text. Search function useful if you want to make the checking criteria Not Case Sensitive.
If Range of Cells Contains Text
We can check for the strings in a range of cells. Here is the formula to find If Range of Cells Contains Text. We can use Count If Formula to check the excel if range of cells contains specific text and return Text.
- CountIf function counts the number of cells with given criteria
- We can use If function to return the required Text
- Formula displays the Text ‘Range Contains Text” if match found
- Returns “Text Not Found in the Given Range” if match not found in the specified range
If Cells Contains Text From List
Below formulas returns text If Cells Contains Text from given List. You can use based on your requirement.
VlookUp to Check If Cell Contains Text from a List:
We can use VlookUp function to match the text in the Given list of Cells. And return the corresponding values.
- Check if a List Contains Text:
=IF(ISERR(VLOOKUP(F1,A1:B21,2,FALSE)),”False:Not Contains”,”True: Text Found”) - Check if a List Contains Text and Return Corresponding Value:
=VLOOKUP(F1,A1:B21,2,FALSE) - Check if a List Contains Partial Text and Return its Value:
=VLOOKUP(“*”&F1&”*”,A1:B21,2,FALSE)
If Cell Contains Text Then Return a Value
We can return some value if cell contains some string. Here is the the the Excel formula to return a value if a Cell contains Text. You can check a cell if there is given string in the Cell and return some string or value in another column.
The formula will return true if it found the match, returns False of no match found. can
Excel if cell contains word then assign value
You can replace any word in the following formula to check if cell contains word then assign value.
Search function will check for a given word in the required cell and return it’s position. We can use If function to check if the value is greater than 0 and assign a given value (example: 1) in the cell. search function returns #Value if there is no match found in the cell, we can handle this using IFERROR function.
Count If Cell Contains Text
We can check If Cell Contains Text Then COUNT. Here is the Excel formula to Count if a Cell contains Text. You can count the number of cells containing specific text.
The formula will Sum the values in Column B if the cells of Column A contains the given text.
Count If Cell Contains Partial Text
We can count the cells based on partial match criteria. The following Excel formula Counts if a Cell contains Partial Text.
- We can use the CountIf Function to Count the Cells if they contains given String
- Wild-card operators helps to make the CountIf to check for the Partial String
- Put Your Text between two asterisk symbols (*YourText*) to make the criteria to find any where in the given Cell
- Add Asterisk symbol at end of your text (YourText*) to make the criteria to find your text beginning of given Cell
- Place Asterisk symbol at beginning of your text (*YourText) to make the criteria to find your text end of given Cell
If Cell contains text from list then return value
Here is the Excel Formula to check if cell contains text from list then return value. We can use COUNTIF and OR function to check the array of values in a Cell and return the given Value. Here is the formula to check the list in range D2:D5 and check in Cell A2 and return value in B2.
If Cell Contains Text Then SUM
Following is the Excel formula to Sum if a Cell contains Text. You can total the cell values if there is given string in the Cell. Here is the example to sum the column B values based on the values in another Column.
The formula will Sum the values in Column B if the cells of Column A contains the given text.
Sum If Cell Contains Partial Text
Use SumIfs function to Sum the cells based on partial match criteria. The following Excel formula Sums the Values if a Cell contains Partial Text.
- SUMIFS Function will Sum the Given Sum Range
- We can specify the Criteria Range, and wild-card expression to check for the Partial text
- Put Your Text between two asterisk symbols (*YourText*) to Sum the Cells if the criteria to find any where in the given Cell
- Add Asterisk symbol at end of your text (YourText*) to Sum the Cells if the criteria to find your text beginning of given Cell
- Place Asterisk symbol at beginning of your text (*YourText) to Sum the Cells if criteria to find your text end of given Cell
VBA to check if Cell Contains Text
Here is the VBA function to find If Cells Contains Text using Excel VBA Macros.
If Cell Contains Partial Text VBA
We can use VBA to check if Cell Contains Text and Return Value. Here is the simple VBA code match the partial text. Excel VBA if Cell contains partial text macros helps you to use in your procedures and functions.
- CheckIfCellContainsPartialText VBA Function returns true if Cell Contains Partial Text
- inStr Function will return the Match Position in the given string
If Cell Contains Text Then VBA MsgBox
Here is the simple VBA code to display message box if cell contains text. We can use inStr Function to search for the given string. And show the required message to the user.
- inStr Function will return the Match Position in the given string
- blnMatch is the Boolean variable becomes True when match string
- You can display the message to the user if a Range Contains Text
Which function returns true if cell a1 contains text?
You can use the Excel If function and Find function to return TRUE if Cell A1 Contains Text. Here is the formula to return True.
Which function returns true if cell a1 contains text value?
You can use the Excel If function with Find function to return TRUE if a Cell A1 Contains Text Value. Below is the formula to return True based on the text value.
Источник
The COUNTIF function counts cells that meet supplied criteria, and returns a count of occurrences found. If no cells meet criteria, COUNTIF returns zero.
The asterisk (*) is a wildcard for one or more characters. By concatenating asterisks before and after the value in D5, the formula will count the value as a substring. In other words, it will count the value if it appears anywhere inside any cell in the range.
Any positive result means the value was found. By comparing the result with the greater than operator (>) and zero, we force a final result of TRUE or FALSE.
With IF
You can nest this formula inside the IF function as the logical test. For example, to return a final result of «Yes» or «No», you can use IF like this:
=IF(COUNTIF(range,"*"&value&"*"),"Yes","No")
EXPLANATION
This tutorial shows how to test if a range contains a cell with text and return a specified value if the formula tests true or false, by using an Excel formula and VBA.
This tutorial provides one Excel method that can be applied to test if a range contains at least one cell that has only text by using a combination of Excel IF and COUNTIFfunctions. In this example, if the COUNTIF function, with the criteria of «*», returns a value of greater than 0, meaning the range contains cells that only captures text, the test is TRUE and the formula will return a «Contains Text» value. Alternatively, if the COUNTIF function returns a value of 0, meaning the range does not have any cells that only capture text, the test is FALSE and the formula will return a «No Text» value.
This tutorial provides one VBA method that can be applied to test if a range contains at least one cell that has only text by looping through each cell in a selected range and using the IsText function to identify if a cell contains only text. As soon as the it identifies the first cell that contains only text it will return a value of «Contains Text» and exit loop. If the range does not contain any cells that contain only text, after looping through each cell in a range, it will return a value «No Text».
FORMULA
=IF(COUNTIF(range,»*»)>0,value_if_true, value_if_false)
ARGUMENTS
range: The range of cells you want to test if they contain only text.
value_if_true: Value to be returned if the range contains at least one cell that has only text.
value_if_false: Value to be returned if the range does not contain any cells that contain only text.