logo
search
Function Problems

How to Use Excel IF Formula to Detect Text Codes in a Column

Maira MehtabMaira Mehtab Sep 30, 2026 868 views

Question details

The user needs an Excel formula to check if a range of cells contains specific text codes (like CODE-1, CODE-2) and return 'None' if they are absent.

How to Use Excel IF Formula to Detect Text Codes in a Column
Product
Excel
Device & OS
not provided
Scenario
Data analysis and text extraction where specific formatted codes need to be identified within a column.
Observed behavior
The user wants to output a specific calculation or filter if codes are detected, and display 'None' when no codes are present in the specified range.
Before you start

Ensure that your version of Excel supports the TEXTAFTER function, which is available in Microsoft 365 and newer versions. If using an older version, alternative functions like COUNTIF or SEARCH might be necessary.

Solution 1Recommended

Using IF, SUM, and TEXTAFTER Functions

This is the most efficient method for newer Excel versions to detect codes with hyphens and numeric suffixes.

This formula extracts the numeric part after a hyphen in your codes, sums the results, and checks if the total is greater than zero to determine if valid codes exist.

1
Select the target cell

Click on the cell where you want the detection result to appear.

2
Enter the formula

Type the formula =IF(SUM(--TEXTAFTER(C1:C36,"-"))>0,"filter","None"). Ensure you adjust the range C1:C36 to match the actual location of your data.

3
Customize the true value

Replace the word "filter" in the formula with your desired calculation, text, or cell reference that should trigger when the codes are detected.

4
Apply the formula

Press the Enter key to evaluate the formula and view the result.

Using IF, SUM, and TEXTAFTER Functions
Formula Breakdown: The double negative (--) converts the text string extracted by TEXTAFTER into a numeric value so that the SUM function can process it.
Efficient Data Processing with WPS Office

Easily Detect and Extract Text Codes using WPS Spreadsheet

WPS Spreadsheet provides powerful formula support, including advanced text manipulation and logical functions perfectly compatible with Microsoft Excel. You can seamlessly apply IF and text-extraction functions to analyze your data quickly and efficiently.

  1. 1. Open your file in WPS Spreadsheet: Launch WPS Office and open your workbook containing the text codes.
  2. 2. Input the formula: Select an empty cell and enter your preferred detection formula, such as =IF(COUNTIF(C1:C36, "*CODE-*")>0, "Action", "None").
  3. 3. Evaluate the result: Press Enter to process the formula. WPS Spreadsheet will instantly calculate and display the output.
  4. 4. Apply across columns: Click and drag the fill handle at the bottom-right of the cell to copy the formula logic to adjacent columns if needed.
Fully compatible with Microsoft Excel formulas and file formatsAdvanced text processing tools for quick data cleaning and extractionLightweight application that handles large datasets smoothlyFree to download and use for everyday office tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why am I getting a #NAME? error with the TEXTAFTER function?

The TEXTAFTER function is only available in Microsoft 365 and newer versions of Excel. If you see a #NAME? error, your version of Excel does not support it. You should use alternative functions like COUNTIF or a combination of SEARCH and RIGHT instead.

How can I detect multiple different codes in the same column?

You can use the COUNTIF function with an array constant to check for multiple codes simultaneously. For example, enter =IF(SUM(COUNTIF(C1:C36, {"*CODE-1*","*CODE-2*"}))>0, "Found", "None").

What does the double minus (--) do in Excel formulas?

The double unary minus (--) is used to coerce a text string that looks like a number into an actual numeric value. This is necessary because text extraction functions return text format, which mathematical functions like SUM cannot calculate directly.