Formula Errors

Excel Formula to Return TRUE or YES If Text Ends With Specific Characters

Emma BrownEmma Brown Oct 29, 2026 870 views

Question details

The user needs an Excel formula to check if the text in a specific cell ends with a certain string (like 'og'). If it does, the formula should return TRUE or YES; if not, the cell should remain blank.

How to Return TRUE or YES When Excel Text Ends in Specific Characters
Product
Excel
Device & OS
not provided
Scenario
Filtering or categorizing data by identifying whether cell values end with a specific suffix or sequence of characters.
Observed behavior
The target cell displays TRUE or YES when the reference cell's value ends with the specified text, and displays nothing (remains blank) when there is no match.
Before you start

Ensure that the cells you are referencing contain text data rather than numbers. Verify there are no hidden trailing spaces at the end of your text, as extra spaces will prevent the formula from recognizing the exact ending.

Solution 1Recommended

Use IF and COUNTIF Functions with a Wildcard

This is the most flexible and highly recommended method. It uses the asterisk (*) wildcard to match any sequence of characters that precede your target text.

By combining the IF function with the COUNTIF function, you can evaluate whether a text condition is met. The asterisk (*) wildcard represents any number of characters, so searching for '*og' specifically targets cells where 'og' is at the very end.

1
Select the target cell

Click on the cell where you want the TRUE or YES result to appear.

2
Enter the formula

Type the following formula: =IF(COUNTIF(AT2,"*og")=1,"TRUE",""). Replace 'AT2' with the reference cell you are evaluating.

3
Customize the output text

If you prefer the result to display YES instead of TRUE, change the formula to =IF(COUNTIF(AT2,"*og")=1,"YES",""). Press Enter to apply.

Use IF and COUNTIF Functions with a Wildcard
Wildcard Placement: Placing the asterisk before the text (*og) checks the end of the string. If you want to check if the text appears anywhere in the cell, use asterisks on both sides (*og*).

Easily Manage Text Formulas with WPS Spreadsheet

WPS Spreadsheet fully supports advanced logical functions, wildcards, and text manipulation tools. You can seamlessly write, troubleshoot, and execute complex formulas like IF and COUNTIF to process your datasets efficiently.

  1. 1. Open your dataset: Launch WPS Spreadsheet and open the document containing the data you want to analyze.
  2. 2. Select the formula cell: Click on the empty cell where you want the TRUE, YES, or blank output to appear.
  3. 3. Input the wildcard formula: Type =IF(COUNTIF(A2,"*og")=1,"TRUE","") into the formula bar at the top of the workspace.
  4. 4. Apply to multiple cells: Press Enter to view the result, then click and drag the fill handle down to apply this logic to the entire column.
Fully compatible with Microsoft Excel formulas, wildcards, and shortcutsUser-friendly interface for building complex nested IF statementsBuilt-in error checking to help you identify and fix formula mistakesFree and lightweight alternative for powerful daily data processing
microsoft office alternative - wps office

Frequently Asked Questions

Why is my COUNTIF wildcard formula not matching the text?

This usually happens due to hidden trailing spaces at the end of the text in your reference cell. If a cell contains 'dog ' (with a space), a formula searching for '*og' will not recognize it. Use the TRIM function, like TRIM(AT2), to remove extra spaces before applying your condition.

How can I check if a cell contains specific text anywhere, not just at the end?

You can change the placement of the wildcard. By putting an asterisk on both sides of the target text (e.g., "*og*"), the COUNTIF function will return a match if 'og' appears at the beginning, middle, or end of the cell's contents.

Is the COUNTIF function case-sensitive?

No, COUNTIF is not case-sensitive. It treats 'og', 'OG', and 'Og' as identical matches. If you require a strict case-sensitive search, you will need to use a combination of the IF, EXACT, and RIGHT functions instead.