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

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

**Excel:** `=IF(TRIM(B2)="Paid","Closed","Chase")` (Every current version)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C |
| --- | --- | --- |
| Invoice | Status (imported) | Action |
| INV-71 | Paid |  |
| INV-72 | Paid |  |
| INV-73 | Unpaid |  |
| INV-74 | Paid |  |
| INV-75 | PAID |  |
| INV-76 | Unpaid |  |

Formula in C2, filled to C7: `=IF(TRIM(B2)="Paid","Closed","Chase")`

Result: Closed; Closed; Chase; Closed; Closed; Chase

## 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.

## Other ways

- `=IF(B2="Paid","Closed","Chase")`: The plain comparison. ("Paid " and " Paid" show Chase.)
- `=IF(TRIM(CLEAN(B2))="Paid","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.

## 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")`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/if-not-matching-text-that-looks-the-same
