Why Your IF Statement Always Returns the “False” Value
You have a payroll formula: =IF(A2="Senior", B2*1.2, B2) — multiply by 1.2 for Senior staff, return base pay otherwise. Every cell in column C returns the base pay. None are getting the 20% Senior bump. You scroll through column A and confirm dozens of rows contain the literal text “Senior”. You retype “Senior” in one cell to be sure — still returns base pay. The IF logic looks airtight. Something about the equality test is silently failing for every single row. IF in Excel does not throw an error when comparisons unexpectedly fail; it cheerfully returns the false branch as if everything is fine. That is what makes this bug so dangerous.
Before You Start: The 60-Second Diagnostic
Three checks:
- Test the equality directly: In an empty cell, type
=A2="Senior". If it returns FALSE for a row that visually matches, the comparison is broken — and IF is downstream of the bug. - Check character-by-character length:
=LEN(A2)against=LEN("Senior"). Any length difference means hidden characters. - Verify the data type: If you are comparing numbers, check
=ISNUMBER(A2)against=ISNUMBER(B2). Number-text mismatches always compare unequal.
Step-by-Step Solution
H2: Diagnose Hidden Whitespace
The most common cause. If =A2="Senior" returns FALSE on a row that looks like “Senior”:
=LEN(A2)
If this returns 7 instead of 6, you have a trailing space. Fix it with TRIM in the formula:
=IF(TRIM(A2)="Senior", B2*1.2, B2)
For a permanent fix, apply TRIM in a helper column and replace the original column with the cleaned values.
H2: Diagnose Number-vs-Text Mismatch
If your IF compares numeric values:
=IF(A2=100, "Match", "No match")
And it always returns “No match” even when A2 displays 100, run =ISNUMBER(A2). If FALSE, A2 is text. Fix:
=IF(VALUE(A2)=100, "Match", "No match")
Or coerce both sides to text:
=IF(A2="100", "Match", "No match")
H2: Diagnose Boolean Coercion
A subtle pattern: =IF(A2, "Yes", "No"). If A2 contains the text “TRUE” (string), Excel does NOT treat it as the Boolean TRUE — it treats text as truthy only if non-empty. The result is “Yes” *regardless* of what the text says.
Fix:
=IF(A2="TRUE", "Yes", "No")
Now you compare against the literal string. Or, for actual Boolean values, ensure the source cell uses formulas returning TRUE/FALSE rather than text.
H2: Diagnose Case Sensitivity (Spoiler: There Is None)
IF’s = operator is not case-sensitive. “senior”, “SENIOR”, and “Senior” all compare equal. If you need case-sensitive comparison:
=IF(EXACT(A2, "Senior"), B2*1.2, B2)
EXACT is case-sensitive. Use it whenever case must distinguish (rare, but real in identifier-matching scenarios).
H2: Diagnose CHAR(160) Non-Breaking Spaces
The cause that survives even TRIM:
=CODE(RIGHT(A2, 1))
If this returns 160, you have a CHAR(160) non-breaking space (common in copied web data). TRIM does NOT remove CHAR(160). Use:
=IF(SUBSTITUTE(A2, CHAR(160), "")="Senior", B2*1.2, B2)
For a complete cleansing wrapper:
=IF(TRIM(SUBSTITUTE(CLEAN(A2), CHAR(160), ""))="Senior", B2*1.2, B2)
Information Gain Box: The Hidden Locale-Decimal Comparison Bug
Here is the cause that confounds international teams: on systems with European locale (where comma is the decimal separator), an IF that compares against a number like 1.5 may always return FALSE because the locale parses 1.5 as text, not number. The formula =IF(A2=1.5, ...) works on US machines but fails on German/French machines when A2 holds a true numeric 1.5. The fix: use locale-independent function-built numbers:
=IF(A2=VALUE("1.5"), B2*1.2, B2)
Or hard-coded computation: =IF(A2=3/2, B2*1.2, B2). Microsoft does not document this clearly; it surfaces only when teams collaborate across locale boundaries and identical formulas behave differently per machine.
Comparison Table: Wrong Way vs. Correct Way
| Hidden Cause | Wrong Way (Always False) | Correct Way |
|---|---|---|
| Trailing whitespace | =IF(A2="Senior", x, y) |
=IF(TRIM(A2)="Senior", x, y) |
| Number stored as text | =IF(A2=100, x, y) |
=IF(VALUE(A2)=100, x, y) |
| Text comparison vs Boolean | =IF(A2, "Yes", "No") (text always truthy) |
=IF(A2="TRUE", "Yes", "No") |
| Case mismatch | =IF(A2="Senior", x, y) (not case-sensitive — usually a non-issue) |
=IF(EXACT(A2, "Senior"), x, y) if you need case sensitivity |
| CHAR(160) contamination | =IF(TRIM(A2)="Senior", x, y) (TRIM does not catch CHAR 160) |
=IF(SUBSTITUTE(CLEAN(A2), CHAR(160), "")="Senior", x, y) |
| Locale-dependent decimals | =IF(A2=1.5, x, y) |
=IF(A2=VALUE("1.5"), x, y) |
| Diagnostic step | Stare at the formula | Test =A2="Senior" in isolation first |
Original Image Descriptions
Screenshot 1: Show a column of “Senior” entries in column A, with column C showing base pay (no 20% bump) using =IF(A2="Senior", B2*1.2, B2). In cell D2, show =A2="Senior" returning FALSE. Below, show =LEN(A2) returning 7 and =LEN("Senior") returning 6. Draw a red circle around the LEN difference and a red arrow pointing to the FALSE comparison. Add a red annotation: “Length differs by 1 = trailing whitespace.”
Screenshot 2: Show the corrected formula =IF(TRIM(SUBSTITUTE(CLEAN(A2), CHAR(160), ""))="Senior", B2*1.2, B2) correctly applying the 20% bump. Draw a red circle around the bulletproof cleansing wrapper functions. Add a red annotation: “Combine TRIM, CLEAN, and SUBSTITUTE to catch every hidden character.”
Frequently Asked Questions
Q: My IF formula visually compares two identical cells but always picks the false branch. What is going on?
A: 99% of the time, the cells differ at the byte level even though they look identical. Use =CODE(MID(A2, n, 1)) for each character position to find where they diverge. Common culprits: a normal space (CHAR 32) versus a non-breaking space (CHAR 160), a hyphen (CHAR 45) versus an em-dash (CHAR 8212), or invisible Unicode marks like CHAR 8203 (zero-width space).
Q: Can I use IF to compare ranges instead of single cells?
A: Standard IF works on single values. For range comparisons that return arrays, use IF inside SUMPRODUCT or wrap with COUNTIF: =IF(COUNTIF(A:A, "Senior")>0, "Found", "Missing"). In Excel 365, IF naturally handles arrays through dynamic array spill.
Q: How can I see all rows where my IF returned FALSE unexpectedly?
A: Add a diagnostic column showing the raw comparison: =A2="Senior". Filter that column for FALSE to see every row that should have matched but did not. Apply your diagnostic functions (LEN, CODE, ISNUMBER) to those specific rows to find what is hidden.