IF Function in Excel: Ultimate Guide

IF Function in Excel: Ultimate Guide
IL Inar Learn
IF Function in Excel — Ultimate Guide Saved
18 min read Excel 2016 · 2019 · 2021 · Microsoft 365 Updated for 2026

The IF function is where almost everyone starts with Excel formulas — and where almost everyone eventually writes a nine-level nested monster that nobody dares to edit. This guide walks through the whole thing with real spreadsheet examples you can type into a blank workbook today.

You will see the syntax broken down argument by argument, six comparison operators, a full worked payroll example, a grade tracker, a commission tier model, plus nested IF, IFS, AND/OR/NOT, text and wildcard tests, date logic, and the ways IF works together with lookups, data validation, and conditional formatting.

In one sentence

The IF function tests a condition and returns one value when the test is TRUE and another when it is FALSE, written as =IF(logical_test, value_if_true, [value_if_false]).

01

What Is the IF Function?

IF is Excel’s branching function. It evaluates a condition — the logical test — and then chooses between two outcomes. The condition must resolve to either TRUE or FALSE; there is no third state and no “maybe”.

That binary nature is the source of both its power and its limits. It is excellent for decisions with two outcomes: pass or fail, over budget or under, in stock or out. It becomes awkward the moment a decision has three or more possible outcomes, which is why nested IF exists and why IFS was added to Excel in 2019.

FunctionIF
CategoryLogical
Arguments2–3
ReturnsAny value
SinceExcel 1.0

How IF evaluates a formula

Take the formula =IF(A2>=60, "Pass", "Fail"). Excel reads it in three steps:

  1. Evaluate the logical test. It computes A2>=60 and produces either TRUE or FALSE. Nothing else is looked at yet.
  2. Pick the matching branch. If the test is TRUE, Excel reads the second argument. If FALSE, the third.
  3. Return that value. Only the chosen branch is evaluated — the other one is never computed, which matters if one branch contains an expensive lookup or a formula that could error.
i
IF is not the only branching option

Excel also has IFS, SWITCH, CHOOSE, and lookup functions like XLOOKUP. Each solves a slightly different shape of problem.

02

Syntax and Arguments

The full signature has three arguments, and only the last one is optional.

Formula syntax
=IF(logical_test, value_if_true, [value_if_false])

Walking through each argument

  1. logical_test — any expression that evaluates to TRUE or FALSE. Usually a comparison such as A2>=60, B2="", or C2<>0.
  2. value_if_true — what to return when the test is TRUE. Can be a number, text in double quotes, a cell reference, or another formula.
  3. value_if_false (optional) — what to return when the test is FALSE. If you omit it, Excel returns the logical value FALSE.
Argument reference
ArgumentRequired?Notes
logical_testRequiredMust resolve to TRUE or FALSE. Numbers count — 0 is FALSE, anything else is TRUE.
value_if_trueRequiredText must be in double quotes: "Pass".
value_if_falseOptionalIf omitted, the cell shows the word FALSE when the test fails.
!
Text must be in double quotes

Writing =IF(A2>=60,Pass,Fail) makes Excel look for defined names called Pass and Fail. It fails with #NAME?. Always wrap literal text in double quotes.

✓
Always supply the third argument

If you leave it out, a failed test returns the word FALSE in the cell. That is almost never what a report should show. Use "" for a blank-looking result, or 0 for a numeric one.

03

Comparison Operators

The logical test is built from comparison operators. These are the six you will use in almost every IF formula you ever write.

The six comparison operators used inside a logical test
OperatorMeaningExampleTRUE when…
=Equal toA2="Yes"A2 contains the text Yes
>Greater thanA2>100A2 holds a number above 100
<Less thanA2<0A2 holds a negative number
>=Greater or equalA2>=60A2 is 60 or higher
<=Less or equalA2<=100A2 is 100 or lower
<>Not equal toA2<>""A2 is not empty

Boundary values — where most bugs live

The single most common off-by-one bug in an IF formula is choosing > when you meant >=. The two differ only at the exact threshold, which is precisely the case that gets tested in reports.

Boundary comparisonBook1.xlsx
A
Score
B
>=60
C
>60
259FailFail
360PassFail
461PassPass
Row 3 is the only difference. A score of exactly 60 passes with >= and fails with >. Decide which behaviour you actually want before you write the formula.
✓
Test the comparison in its own cell first

When a formula misbehaves, paste just the logical test into an empty cell — for example =A2>=60 on its own. It returns TRUE or FALSE, which tells you whether the problem is the test or the branches.

04

Real-World Examples

These are the patterns that come up over and over in actual workbooks. Each one includes a spreadsheet mockup showing exactly what the data looks like and the formula that goes in each cell.

Example 1 — Payroll: overtime pay calculation

Pay the standard rate up to 40 hours, and 1.5× the rate for any hours beyond 40.

Payroll — Weekly HoursPayroll.xlsx
A
Employee
B
Hours
C
Rate
D
Regular
E
Overtime
F
Total
2Ana Torres3822.00836.000.00836.00
3Ben Okafor4718.50740.00194.25934.25
4Carla Reyes4025.001,000.000.001,000.00
Formulas: D2 → =IF(B2>40,40*C2,B2*C2) · E2 → =IF(B2>40,(B2-40)*C2*1.5,0) · F2 → =D2+E2
Payroll formulas
' Regular pay — cap hours at 40
=IF(B2>40, 40*C2, B2*C2)

' Overtime pay — hours beyond 40, at 1.5x
=IF(B2>40, (B2-40)*C2*1.5, 0)

' Total pay
=D2+E2

Example 2 — Student grade tracker with a nested IF

The classic use of nested IF: convert a numeric score into a letter grade.

Grades — Fall SemesterGrades.xlsx
A
Student
B
Score
C
Grade
D
Status
2Priya Shah94APass
3Marcus Lee82BPass
4Elena Novak58FFail
5Tomás Alves90APass
Formulas: C2 → =IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C",IF(B2>=60,"D","F")))) · D2 → =IF(B2>=60,"Pass","Fail")
Grade formulas
' Nested IF — most restrictive test first
=IF(B2>=90,"A",
   IF(B2>=80,"B",
      IF(B2>=70,"C",
         IF(B2>=60,"D","F"))))

' Simple pass/fail alongside it
=IF(B2>=60,"Pass","Fail")
!
Order matters — and getting it wrong is silent

Because Excel stops at the first TRUE, the tests must be ordered from most restrictive to least. Reverse the order and a 94 would match the first test B2>=60 and return “D”.

Example 3 — Sales commission tiers

Commission is a percentage that changes as sales cross thresholds.

Sales Commission — Q1Commission.xlsx
A
Rep
B
Sales
C
Rate
D
Commission
2J. Martin8,4005%420.00
3K. Adeyemi18,2008%1,456.00
4L. Petrov41,50012%4,980.00
Tier rule: 5% up to $10,000 · 8% to $25,000 · 12% above
Formulas: C2 → =IF(B2>25000,0.12,IF(B2>10000,0.08,0.05)) · D2 → =B2*C2

Example 4 — Invoice aging report

Accounts receivable reports bucket invoices by how overdue they are.

Invoice AgingAR.xlsx
A
Invoice
B
Amount
C
Due
D
Days Late
E
Bucket
2INV-10421,2502026-10-15-16Current
3INV-10393,4002026-09-12171–30 days
4INV-10358202026-08-204031–60 days
5INV-10285,6002026-07-019060+ days
Formulas: D2 → =IFERROR(TODAY()-C2,"No date") · E2 → =IF(D2<=0,"Current",IF(D2<=30,"1–30 days",IF(D2<=60,"31–60 days","60+ days")))

Example 5 — Data quality check

When you import data, you need a single flag that says whether a row is usable.

Customer Import — ValidationImport.xlsx
A
Name
B
Email
C
Age
D
Country
E
Status
2Sara Alisara@example.com34UAEOK
3Ravi Kumarravi@example.com-3IndiaReview
4Lena Fischerlena@example.com41GermanyOK
Formula in E2: =IF(OR(A2="",B2="",C2<0,C2>120,D2=""),"Review","OK")
05

Nested IF, IFS, and When to Stop Nesting

A nested IF puts one IF function inside another, in the value_if_false slot. It is how Excel handled multi-way decisions before IFS existed, and it still works perfectly well — it just gets hard to read quickly.

Nested IF — 4 levels deep
=IF(B2>=90,"A", IF(B2>=80,"B", IF(B2>=70,"C", IF(B2>=60,"D","F"))))
Each new band adds a level of indentation and another closing parenthesis at the end.
IFS — flat and readable
=IFS(B2>=90,"A", B2>=80,"B", B2>=70,"C", B2>=60,"D", TRUE,"F")
Each band is one line. Adding a band means adding one line in the right place.

IFS was introduced in Excel 2019 and Microsoft 365. It takes pairs of condition and result, reads top to bottom, and returns the first match. The final TRUE,"F" pair acts as a catch-all.

Choosing the right function for the shape of the decision
FunctionBest forAvailability
IFExactly two outcomesAll versions
IFSThree or more ranges of a valueExcel 2019, M365
SWITCHMatching one value against exact optionsExcel 2019, M365
XLOOKUPLooking up a value in a tableM365, Excel 2021
VLOOKUPSame as XLOOKUP, older compatibilityAll versions
Four approaches to the same grade problem
' 1. Nested IF — works everywhere, gets ugly fast
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C",IF(B2>=60,"D","F"))))

' 2. IFS — flat, readable, modern Excel only
=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",B2>=60,"D",TRUE,"F")

' 3. VLOOKUP with approximate match — thresholds in a table
=VLOOKUP(B2,$F$2:$G$6,2,TRUE)

' 4. XLOOKUP with approximate match — modern syntax
=XLOOKUP(B2,$F$2:$G$6,$G$2:$G$6,,-1)
✓
Past three levels, switch to a lookup table

Nested IF and IFS both bury the thresholds inside a formula. A lookup table puts them in cells where anyone can see and edit them without touching the formula.

!
Modern Excel allows 64 nested IFs. Readability allows about three.

The limit is not the constraint. The constraint is the next person who has to maintain the formula. If you can’t read it in one glance, refactor it.

06

IF with AND, OR, and NOT

A single comparison is often not enough. That is what AND, OR, and NOT are for — and they go inside the logical test, not around the IF.

Combining conditions
' AND — every condition must be true
=IF(AND(B2>=60,C2>=60),"Pass both","Retake one")

' OR — at least one condition must be true
=IF(OR(B2>=90,C2>=90),"Honours","Standard")

' NOT — invert a condition
=IF(NOT(ISBLANK(B2)),"Has value","Empty")

' Combined — either condition, but not both
=IF(OR(AND(B2>=60,C2<60),AND(B2<60,C2>=60)),"Retake one","Review")

AND, OR, NOT at a glance

Logical operators and what they return
FunctionReturns TRUE when…Returns FALSE when…
AND(a, b, …)Every argument is TRUEAny argument is FALSE
OR(a, b, …)At least one argument is TRUEEvery argument is FALSE
NOT(a)The argument is FALSEThe argument is TRUE

Common mistakes with AND and OR

01

Wrapping the IF instead of the test

=AND(IF(A2>60,...)) is wrong. The AND belongs inside the logical test: =IF(AND(A2>60,B2<100),...).

02

Using OR when you mean AND

“A and B must both be true” is AND. OR is “at least one”. These two are mixed up more than any others.

03

Forgetting that blank cells are FALSE

An empty cell in an AND test fails the test. Guard with NOT(ISBLANK(A2)) if you want blanks to be ignored.

04

Using AND/OR instead of * and +

Inside SUMPRODUCT and array formulas, AND and OR do not work. Use * for AND and + for OR instead.

!
AND and OR return TRUE/FALSE, not 1/0

That matters when you multiply them. In an IF test, TRUE/FALSE is fine. In an arithmetic context, wrap them with a double negative -- or use N() to convert.

07

IF with Text, Wildcards, and Case Sensitivity

Text comparisons are where IF gets subtle. The = operator is case-insensitive, does not support wildcards, and treats “East” and “East ” (with a trailing space) as different values. Each of these catches people at some point.

Case-insensitive vs case-sensitive

Case-insensitive — the default
=IF(A2="yes","Y","N")
Matches “yes”, “Yes”, “YES”, “yEs”. Useful when data entry is inconsistent.
Case-sensitive — use EXACT
=IF(EXACT(A2,"yes"),"Y","N")
Only matches lowercase “yes”. Use when case itself carries meaning.

Wildcards — where they work and where they do not

The = operator inside IF does not support wildcards. That is a common surprise for people who use SUMIF and COUNTIF, which do support wildcards.

Wildcard support across common functions
FunctionWildcards?Case-sensitive?
SUMIF / SUMIFSYesNo
COUNTIF / COUNTIFSYesNo
IF with =NoNo
IF with SEARCH or ISNUMBERYes (implicit)No
IF with EXACTNoYes
Text patterns
' Exact text match (case-insensitive)
=IF(A2="East","Yes","No")

' Case-sensitive match
=IF(EXACT(A2,"EAST"),"Yes","No")

' Contains "East" anywhere (case-insensitive)
=IF(ISNUMBER(SEARCH("East",A2)),"Contains","Not found")

' Starts with "North"
=IF(LEFT(A2,5)="North","Northern","Other")

' Ends with "Ltd"
=IF(RIGHT(A2,3)="Ltd","Company","Other")

' Blank cell
=IF(A2="","Empty","Has value")

' Trailing spaces often cause false matches — clean first
=IF(TRIM(A2)="East","Yes","No")
✕
Trailing spaces break text matches silently

“East” and “East ” are not equal to Excel. Neither is “East” and “East” with a non-breaking space. This is the single most common cause of a text IF returning the wrong branch. Wrap the cell in TRIM() before comparing, or clean the source data with Text to Columns.

✓
Use SEARCH for contains, FIND for case-sensitive contains

SEARCH is case-insensitive and supports wildcards. FIND is case-sensitive and does not. Both return a number if found and #VALUE! if not, which is why they are almost always wrapped in ISNUMBER.

08

IF with Dates

Dates are numbers underneath. A comparison like A2>TODAY() works exactly like a numeric comparison — but only if the cell really contains a date and not a text string that looks like one.

Common date comparisons

Date logic
' Overdue?
=IF(A2=TODAY(),A2<=TODAY()+7),"Due soon","Later")

' Same month and year as today
=IF(AND(YEAR(A2)=YEAR(TODAY()),MONTH(A2)=MONTH(TODAY())),"This month","Other")

' Older than 30 days
=IF(TODAY()-A2>30,"Ageing","Fresh")

' Weekend check
=IF(WEEKDAY(A2,2)>5,"Weekend","Weekday")

' Quarter label
=IF(MONTH(A2)<=3,"Q1",IF(MONTH(A2)<=6,"Q2",IF(MONTH(A2)<=9,"Q3","Q4")))

Date functions that pair with IF

Date helpers commonly used inside a logical test
FunctionWhat it returnsTypical use inside IF
TODAY()Today's date, no timeOverdue checks, YTD boundaries
NOW()Current date and timeTimestamp comparisons
YEAR()Year part of a dateFiscal year bucketing
MONTH()Month number 1–12Quarter or season logic
WEEKDAY(date,2)Day of week, 1 = MondayWeekend checks
EOMONTH(date,0)Last day of the monthMonth-end checks
DATEDIF(start,end,"y")Completed years betweenAge or tenure bands
✕
Text dates break every comparison silently

If a cell shows 01/05/2026 but is stored as text, A2<TODAY() will compare a string to a number. Excel does not throw an error — it returns the wrong answer. Verify with =ISNUMBER(A2). A real date returns TRUE.

!
Never hard-code dates as text in the formula

Writing "2026-01-01" inside a comparison makes Excel convert it using your locale. On a machine with a different regional setting the formula breaks. Always use DATE(2026,1,1) or a cell reference.

09

IF with Lookups, IFERROR, and IFNA

IF rarely works alone. In real workbooks it wraps lookups, guards divisions, and validates inputs before passing them to another function. The three functions below are the ones you will reach for most often.

IFERROR — the universal safety net

IFERROR(value, value_if_error) returns the first argument if it works and the second if it produces any error. It replaces the older, clunkier IF(ISERROR(...),...) pattern.

IFERROR patterns
' Guarding a division by zero
=IFERROR(A2/B2,"Check inputs")

' Guarding a lookup that finds nothing
=IFERROR(VLOOKUP(A2,Products,3,FALSE),"Not found")

' Guarding a nested formula
=IFERROR(IF(A2>0,A2/B2,0),"Check inputs")

IFNA — only catches missing lookups

IFNA catches #N/A and nothing else. Use it when you want a lookup miss to show a friendly message, but you still want other errors (typos, bad references) to surface so you notice them.

IFNA vs IFERROR
' IFNA — only handles missing lookups, other errors still show
=IFNA(VLOOKUP(A2,Products,3,FALSE),"Not found")

' IFERROR — hides every kind of error
=IFERROR(VLOOKUP(A2,Products,3,FALSE),"Not found")

IF combined with a lookup — driving a result from a table

Rather than nesting five IFs to pick a value, put the values in a small table and let a lookup do the choosing. IF then handles the edge cases around the lookup.

Lookup table replaces nested IFRates.xlsx
E
Min Sales
F
Rate
205%
3100008%
42500012%
Formula: =IFERROR(VLOOKUP(B2,$E$2:$F$4,2,TRUE),"No tier") — the lookup picks the rate, IFERROR handles a row that has no sales value at all.
Nested IF for tiering
=IF(B2>25000,0.12, IF(B2>10000,0.08, IF(B2>0,0.05,"No tier")))
Every threshold is buried in the formula. Changing 10,000 to 12,000 means editing the formula.
Lookup table for tiering
=IFERROR( VLOOKUP(B2,$E$2:$F$4,2,TRUE), "No tier")
Thresholds live in cells. Changing 10,000 to 12,000 is one cell edit.
✓
Build the formula first, wrap it in IFERROR last

If you wrap too early, IFERROR hides your own mistakes and you never notice that the lookup is returning the wrong column. Get the formula working, then add the guard.

i
IFERROR hides every error — including real bugs

A misspelled function, a broken reference, a wrong column index — IFERROR swallows them all and shows your friendly message. That is exactly what you want in a finished workbook, and exactly what you do not want while you are still building it.

10

IF in Data Validation and Conditional Formatting

IF logic does not only live in cells. Data Validation rules and Conditional Formatting rules both use the same TRUE/FALSE thinking, and the same operators you already know from IF. Learning to spot these patterns makes both features much less mysterious.

Data Validation — reject bad input

Data Validation rules run a hidden logical test. If the test returns TRUE, the input is accepted. If FALSE, Excel rejects it. Everything you know about IF logical tests applies directly.

  1. Select the cells you want to validate, for example a whole column of scores.
  2. Open Data → Data Validation. Choose Custom from the Allow list.
  3. Type the logical test — the same condition you would put in an IF. Do not write =IF(...); just the test itself.
Data Validation formulas
' Score must be between 0 and 100
=AND(A2>=0, A2<=100)

' Email must contain "@"
=ISNUMBER(SEARCH("@", B2))

' Date must not be in the past
=A2>=TODAY()

' Text must be one of three allowed values
=OR(C2="Open", C2="Closed", C2="Pending")

' Discount must not exceed the price
=D2<=C2

Conditional Formatting — highlight rows that match a rule

Conditional Formatting also runs a hidden logical test, cell by cell, and applies formatting wherever the test is TRUE. The same six operators, the same AND/OR logic, the same trap of testing the wrong range.

Conditional Formatting formulas
' Highlight the whole row when status is "Overdue"
=$D2="Overdue"

' Highlight scores below 60
=A2<60

' Highlight dates falling in the next 7 days
=AND(A2>=TODAY(), A2<=TODAY()+7)

' Highlight duplicates across two columns
=COUNTIF($A$2:$A$100,$A2)>1

' Alternate row shading — every even row
=MOD(ROW(),2)=0
!
The single biggest Conditional Formatting mistake: relative vs absolute references

To highlight an entire row based on one column, the column reference must be locked with a dollar sign and the row must be free: =$D2="Overdue". Writing =$D$2="Overdue" highlights nothing, and writing =D2="Overdue" highlights only the cells in column D. This one character difference trips up almost everyone the first time.

✓
Prototype the test in a spare cell first

Before typing a rule into Data Validation or Conditional Formatting, write the same logical test in an empty column and copy it down. If the column shows the TRUE/FALSE pattern you expect, the rule will work. If it doesn't, the rule won't either.

11

Common Errors and How to Fix Them

Most IF problems fall into one of a handful of patterns. Each one below has a known cause and a known fix.

✕
#NAME? — unquoted text or misspelled function

You wrote =IF(A2>=60,Pass,Fail). Excel looks for defined names called Pass and Fail and finds nothing. The same error appears if the function name itself is misspelled.

Fix: wrap text criteria in double quotes: "Pass". Check the spelling of the function.

✕
#VALUE! — comparing incompatible types

The formula is comparing text against a number, or a referenced cell contains an error value. For example =IF(A2>100,...) where A2 contains the text "n/a".

Fix: guard the input with ISNUMBER or ISTEXT, or wrap the whole formula in IFERROR.

!
The word FALSE appears in the cell

You omitted the third argument. When the test fails, Excel returns the logical value FALSE, which shows up as text.

Fix: supply a third argument — even just "" for a blank-looking result.

!
Wrong branch is chosen — order of nested tests

In a nested IF, Excel stops at the first TRUE. A loose test placed above a restrictive one swallows every case below it.

Fix: order tests from most restrictive to least. >=90 before >=80 before >=70.

!
Off-by-one at the boundary

A score of exactly 60 passes with >=60 and fails with >60. Text matches fail silently if the cell has trailing spaces.

Fix: test the boundary case directly. Wrap text cells in TRIM() before comparing.

!
Text comparison fails but the text looks identical

Trailing spaces, non-breaking spaces, or hidden characters in the source data. “East” and “East ” are not equal to Excel.

Fix: clean with TRIM(), or use Text to Columns to normalize the source.

i
Case-sensitive match needed

The = operator is case-insensitive. For a case-sensitive test, use EXACT: =IF(EXACT(B2,"yes"),1,0).

Error-handling patterns
' Without protection
=IF(A2>0,A2/B2,0)

' With protection
=IFERROR(IF(A2>0,A2/B2,0),"Check inputs")

' Lookup that finds nothing
=IFERROR(VLOOKUP(A2,Products,3,FALSE),"Not found")

' Only catch missing lookups, not other errors
=IFNA(VLOOKUP(A2,Products,3,FALSE),"Not found")
12

Best Practices for Office Workbooks

These habits keep IF formulas understandable months later, and working when a colleague inherits the file.

01

Always supply the third argument

Omitting it returns the word FALSE, which is rarely what a report should show.

02

Order tests most restrictive first

Excel stops at the first TRUE. A loose test at the top swallows every case below it.

03

Decide on > versus >=

Boundary values are where most off-by-one bugs live. Check the exact threshold case.

04

Move thresholds into cells

A rate buried in a formula is invisible. A rate in a named cell is editable data.

05

Prefer IFS past three levels

Flat beats nested whenever the Excel version allows it.

06

Return numbers where you can

1 and 0 can be summed and charted; "Yes" and "No" cannot.

07

Guard the inputs

Check for blanks and non-numbers before comparing. It prevents most #VALUE! errors.

08

Add IFERROR last

Build the formula so it works, then wrap it. Wrapping early hides your own mistakes.

09

Clean text before comparing

Wrap in TRIM() or normalize with Text to Columns. Trailing spaces break text IFs silently.

10

Use real dates, not text

Date comparisons only work on real dates. Verify with ISNUMBER().

11

Break long formulas across lines

Press Alt+Enter inside the formula bar to add a line break.

12

Test with boundary values

Feed the formula the value at the exact threshold. That is where the bug is.

13

Practice Questions

Try these before opening the answers. They use the examples from earlier in the guide.

  1. Q1. Cell A1 contains 75. What does =IF(A1>=60,"Pass","Fail") return?
    Answer: Pass. 75 is greater than or equal to 60, so the second argument is returned.
  2. Q2. Cell A1 contains 45. What does =IF(A1>=90,"A",IF(A1>=80,"B",IF(A1>=70,"C",IF(A1>=60,"D","F")))) return?
    Answer: F. 45 fails every test down to the catch-all.
  3. Q3. Cell A1 contains 15000. What rate does =IF(A1>25000,0.12,IF(A1>10000,0.08,0.05)) return?
    Answer: 0.08. 15000 is not above 25000 but it is above 10000.
  4. Q4. What does =IF(AND(5>3,2>4),"Yes","No") return?
    Answer: No. AND requires both conditions to be TRUE. 2>4 is FALSE, so the whole test is FALSE.
  5. Q5. What does =IF(OR(10>5,1>2),"OK","BAD") return?
    Answer: OK. OR requires only one condition to be TRUE. 10>5 is TRUE.
  6. Q6. Why does =IF(A2="East","Yes","No") return "No" when A2 visually shows "East"?
    Answer: Most likely there are trailing or leading spaces. Excel treats "East" and "East " as different. Wrap A2 in TRIM(): =IF(TRIM(A2)="East","Yes","No").
14

Frequently Asked Questions

What is the IF function in Excel?

IF is a logical function that tests a condition and returns one value when the condition is TRUE and another when it is FALSE. Its syntax is =IF(logical_test, value_if_true, [value_if_false]).

How many arguments does the IF function take?

Three: logical_test (required), value_if_true (required), and value_if_false (optional). If you omit the third, Excel returns the logical value FALSE when the test fails.

Why do I need quotation marks around text in IF?

Excel treats anything unquoted as a name, function, or cell reference. Text values must be wrapped in double quotes: =IF(B2>=60,"Pass","Fail").

How many nested IF functions can Excel handle?

Modern Excel allows up to 64 levels of nesting. Readability falls apart long before that. If you need more than two or three levels, switch to IFS, SWITCH, or a lookup table.

Is IFS better than nested IF?

For most multi-condition cases, yes. IFS reads top to bottom with no repeated nesting. It requires Excel 2019 or later, or Microsoft 365.

How do I use IF with AND or OR?

Wrap the conditions inside the logical_test: =IF(AND(B2>=60,C2>=60),"Pass","Fail") requires both, while =IF(OR(B2>=90,C2>=90),"Honours","Standard") requires only one.

Why does my IF formula return #VALUE!?

#VALUE! usually means the formula is comparing incompatible types — text against a number — or a referenced cell contains an error. Guard with ISNUMBER or ISTEXT.

Why does my IF formula return #NAME?

#NAME? almost always means unquoted text, a misspelled function name, or a missing closing parenthesis.

Can IF return a genuinely blank cell?

Not truly blank. IF can return an empty string with "", which looks blank but is still a text value — ISBLANK on that cell returns FALSE.

How do I make IF case-sensitive?

The = operator is case-insensitive. For a case-sensitive test, use EXACT: =IF(EXACT(B2,"yes"),1,0).

Should I use IF or IFERROR?

They solve different problems. IF tests a condition you define; IFERROR catches any error the formula produces. Use IFERROR around formulas that may fail, and IF for branching logic.

Can IF compare dates?

Yes, provided the cells contain real dates, not text that looks like dates. Use =IF(A2<TODAY(),"Overdue","On track"). Verify with =ISNUMBER(A2) if you are unsure.

Why does my text IF return the wrong branch when the cells look identical?

Trailing or leading spaces. Excel treats "East" and "East " as different values. Wrap the cell in TRIM() before comparing.

15

Key Takeaways

  • IF tests a condition and returns one value for TRUE and another for FALSE.
  • The syntax is =IF(logical_test, value_if_true, [value_if_false]).
  • Text values must be wrapped in double quotes or you get #NAME?.
  • Always supply the third argument — omitting it returns the word FALSE.
  • >= includes the boundary, > excludes it.
  • In nested IF, order tests from most restrictive to least.
  • Past three levels, switch to IFS — it is flat and far easier to audit.
  • Put AND and OR inside the logical test, not around the IF.
  • Guard against blanks and non-numbers with ISBLANK and ISNUMBER.
  • Use IFERROR to replace raw errors with readable messages — but add it last.
  • For banded thresholds, a lookup table beats a nested IF every time.
  • The = operator is case-insensitive. Use EXACT for case-sensitive matches.
  • IF does not support wildcards. Use SEARCH or ISNUMBER for contains checks.
  • Clean text with TRIM() — trailing spaces break text comparisons silently.
  • Date comparisons only work on real dates. Verify with ISNUMBER().
  • The same logical tests drive Data Validation and Conditional Formatting rules.
  • Break long formulas across lines with Alt+Enter.
16

What to Learn Next

IF is the gateway to Excel's whole logical and lookup family. Once it is comfortable, the natural next steps are the functions that replace it in more complex workbooks.

Start with the logical functions that pair with IF — ifs-function, and-or-functions, and iferror-function.

From there, move into lookups and conditional sums: xlookup-function, vlookup-function, sumif-function, and sumifs-function.

Inar Learn
Inar Learnhttps://inarlearn.com
Inar Learn is an innovative online learning platform offering high-quality courses, tutorials, and resources to help learners gain practical skills and grow their knowledge.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here