Formula Errors

How to Fix Excel Formula Returning 0 When Text Appears to Match

Aamir Naveed AkramAamir Naveed Akram Nov 10, 2026 868 views

Question details

The user's text comparison formula is returning 0 because it fails to recognize an apparent text match in a specific cell.

How to Fix Excel Formula Returning 0 When Text Appears to Match
Product
Excel
Device & OS
not provided
Scenario
Comparing text values in spreadsheet cells using a matching formula.
Observed behavior
The formula evaluates to 0 instead of recognizing the match due to hidden spaces, trailing characters, or case-sensitive logic.
Before you start

Double-click the source cell and place your cursor at the end of the text to visually check for any hidden leading or trailing spaces before modifying your formulas.

Solution 1Recommended

Use the TRIM Function to Remove Extra Spaces

Invisible trailing or leading spaces are the most common cause of false mismatches in text comparisons. The TRIM function automatically cleans these up.

When data is imported or typed manually, extra spaces are often accidentally included at the end of a word. A value like 'meets ' will not match 'meets' in a formula.

The TRIM function removes all extra spaces from text except for single spaces between words.

1
Select the formula cell

Click on the cell containing your text comparison formula that is currently returning 0.

2
Wrap the cell reference with TRIM

Modify your formula to include the TRIM function around the target cell reference. For example, change =IF(AR15="meets", 1, 0) to =IF(TRIM(AR15)="meets", 1, 0).

3
Apply the formula

Press Enter to update the calculation. The comparison will now ignore any accidental leading or trailing spaces in the source cell.

Use the TRIM Function to Remove Extra Spaces
Data Standardization: Using TRIM ensures that accidental spaces typed during data entry do not break your critical lookup and comparison formulas.
Advanced Spreadsheet Tool

Fix Formula Errors Quickly with WPS Spreadsheet

WPS Spreadsheet offers powerful formula auditing and built-in text manipulation functions like TRIM, UPPER, and LOWER to help you effortlessly clean your data and ensure accurate comparisons.

  1. 1. Open your workbook: Launch WPS Spreadsheet and open the file containing the text matching error.
  2. 2. Select the error cell: Click on the cell where the formula is incorrectly returning 0.
  3. 3. Edit the formula: Use the Formula bar to insert the TRIM() or LOWER() function around your cell references.
  4. 4. Apply and drag: Press Enter to instantly fix the error, then drag the fill handle to apply the corrected formula to other rows.
Fully compatible with Microsoft Excel formulas, functions, and file formats (XLSX).Built-in data cleaning tools to easily remove spaces and format text.Free, lightweight, and features an intuitive interface for managing complex data.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my VLOOKUP return #N/A when the text appears to match?

Similar to basic formulas, VLOOKUP requires a precise match. If the lookup value or the table array contains trailing spaces or non-breaking spaces, VLOOKUP will fail. Use the TRIM function to clean both the lookup value and your source data columns.

How can I easily spot invisible trailing spaces in my spreadsheet?

You can use the =LEN(cell) formula to count the exact number of characters in a cell. If the character count is higher than the visible letters in the word (for example, 'meets' showing a length of 6 instead of 5), you have hidden spaces.

Is the equals sign (=) in basic formulas case-sensitive?

No, a standard equals comparison (e.g., A1="Meets") is not case-sensitive by default. However, if you are using the EXACT function, it will strictly enforce case sensitivity and return FALSE if the capitalization differs even slightly.

How do I remove non-breaking spaces that TRIM doesn't fix?

TRIM removes standard spaces (character 32) but often leaves non-breaking spaces (character 160) commonly found in copied web data. You can remove these by wrapping your cell in the SUBSTITUTE function: =TRIM(SUBSTITUTE(A1, CHAR(160), " ")).