Spreadsheet Practice

Why is my IF formula not matching text that looks the same?

Formula (Excel and Google Sheets)

=IF(TRIM(B2)="Paid","Closed","Chase")

The cell has hidden spaces, so "Paid " isn't "Paid". Trim it in the test: =IF(TRIM(B2)="Paid","Closed","Chase").

Result on the example
one result per row in C2, filled down to C7
Works in
Every current version
Google Sheets
Same formula

See it work

The formula is already in C2, filled down to C7. Change any input and the result updates, or edit the formula to experiment.

How it works

Imported text often carries spaces you can't see: "Paid " is not equal to "Paid", so the IF goes the wrong way. TRIM removes spaces at both ends (and doubled spaces inside) before the comparison. Case isn't the problem: "PAID" already matches, because = ignores case.

=IF(TRIM(B2)="Paid","Closed","Chase")

Result"Closed"

  1. B2"Paid"

    The value in B2.

  2. TRIM(B2)"Paid"

    TRIM: Removes extra spaces, leaving single spaces between words.

    • textB2"Paid"
  3. TRIM(B2)="Paid"TRUE

    The = operator tests whether the two sides are equal.

  4. IF(TRIM(B2)="Paid","Closed","Chase")"Closed"

    IF: Returns one value if a test is true, another if false.

    • logical_testTRIM(B2)="Paid"TRUE
    • value_if_true"Closed"
    • value_if_false"Chase"not used

In Google Sheets

The same formula works in Google Sheets: =IF(TRIM(B2)="Paid","Closed","Chase"). We ran it in Google Sheets mode on the same data and it returns the same results.

Other ways to do it

Each one was run on the same example sheet.

FormulaResultWhen to use it
=IF(B2="Paid","Closed","Chase")Closed, Chase, Chase…Different resultThe plain comparison. "Paid " and " Paid" show Chase.
=IF(TRIM(CLEAN(B2))="Paid","Closed","Chase")Closed, Closed, Chase…CLEAN also strips line breaks and other non-printing characters that come with pasted data.

Common mistakes

  • Non-breaking spaces from web pages survive TRIM. Replace them first: SUBSTITUTE(B2,CHAR(160)," ").
  • Check a suspicious cell with =LEN(B2): "Paid " has 5 characters.

Try it yourself

Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.

Why is my IF formula not matching text that looks the same

In C2, show "Closed" when the status is Paid, even with stray spaces around it, otherwise "Chase". Fill down to C7.

Questions

How do I clean the whole column?

Helper column =TRIM(B2), then Paste Values over the original.

How do I make the comparison case-sensitive?

=IF(EXACT(TRIM(B2),"Paid"),"Closed","Chase").

Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.