Excel Practice Test

โ–ถ

Most spreadsheet headaches come back to the same family of formulas, and the IF function sits right in the middle of them. You already know the basic shape: =IF(test, value_if_true, value_if_false). Fine. But the moment your test has two conditions, or you need to ignore blank cells, or a #N/A error breaks your summary row, the simple form starts to fall apart. That is where examples earn their keep.

This guide skips the introductory syntax (the sibling article how to use the IF function in Excel covers that) and focuses on the example patterns people search for again and again. We will look at IF combined with AND, OR, ISBLANK, ISNUMBER+SEARCH, IFERROR, AVERAGE and AVERAGEIF, plus nested IF chains and the newer IFS function for else-if logic.

Every formula here is copy-paste safe. You can drop it into Excel 365, Excel 2019, Excel 2021, or Excel for the web with only minor tweaks. Where a function is version-specific (IFS, for instance), the article calls it out. Read top-to-bottom or jump to the section that matches the error you are looking at right now.

One thing before we dig in. The order of the examples follows how questions actually come up in real spreadsheets: multi-condition checks first, because they are the most-asked. Empty-cell handling next, because it is the most-skipped (and the most-debugged). Partial text matching, error trapping, and conditional averages after that. Each example includes the version of Excel it works in and the most common breakage mode, so you can short-circuit the debug cycle if your formula misbehaves.

Why these IF patterns matter

7+
common IF variants covered
1980
year IF was added to Excel
64
max nesting depth (modern Excel)
0
add-ins needed to use any of these

IF with AND: testing multiple conditions at once

The first pattern people ask about: how do I check that two things are true before returning a result? The answer is AND() nested inside the IF test. AND returns TRUE only if every argument evaluates to TRUE, which is exactly what you want for a strict gate.

Say column B holds a score out of 100 and column C holds attendance percent. A student passes only if score is at least 70 AND attendance is at least 80:

=IF(AND(B2>=70, C2>=80), "Pass", "Retake")

Three things to notice. First, AND can take up to 255 arguments โ€” you are not limited to two checks. Second, AND short-circuits internally, so order does not affect the result (unlike some programming languages). Third, blank cells inside AND are treated as FALSE, which sometimes bites people. If B2 is empty, the AND collapses and you get "Retake," not an error.

Need three conditions? Just keep adding:

=IF(AND(B2>=70, C2>=80, D2="Submitted"), "Pass", "Retake")

It reads almost like English, and that readability is why AND is preferred over multiplying boolean expressions together โ€” even though =(B2>=70)*(C2>=80) technically works the same way.

If every condition must be true, use AND. Reaching for nested IFs to mimic AND makes the formula longer and harder to audit. A good rule: when you find yourself writing IF(IF(IF(, stop and ask whether AND or IFS would do the job in one line.

IF with OR: any condition can trigger the result

OR is the looser sibling. It returns TRUE if at least one argument is TRUE. Useful when several different inputs should fire the same outcome. Flagging risky orders is a classic case โ€” maybe an order is risky if the amount exceeds $5,000, OR the country is on a watchlist, OR the customer is brand new:

=IF(OR(B2>5000, C2="HighRisk", D2<TODAY()-30), "Review", "OK")

Mixed AND/OR logic is allowed and very common. Pass students who scored 70+ AND either attended 80% of classes OR submitted the makeup assignment:

=IF(AND(B2>=70, OR(C2>=80, D2="Makeup")), "Pass", "Retake")

Watch your parentheses here โ€” that is where most "Excel says my formula is broken" tickets come from. A trick: write the inner condition on its own first in a free cell, confirm the boolean output is TRUE or FALSE as expected, then copy it into the IF wrapper. Building from the inside out beats trying to debug a 90-character formula in one shot.

One more thing worth noting about OR. It is the natural choice for "any of these flags" checks, but it can also model an exclusion list. If you want to skip rows where status is "Closed", "Cancelled", or "Refunded":

=IF(OR(A2="Closed", A2="Cancelled", A2="Refunded"), "", B2*C2)

For longer exclusion lists, you can replace the chained OR with a single MATCH against a range โ€” cleaner and easier to maintain when the list grows:

=IF(ISNUMBER(MATCH(A2, ExcludeList, 0)), "", B2*C2)

Pick the right combiner

๐Ÿ”ด AND

All conditions must be TRUE. Strict gate. Accepts up to 255 arguments. Treats blanks as FALSE and short-circuits internally so argument order does not affect the result.

๐ŸŸ  OR

Any one condition can be TRUE. Loose match. Up to 255 arguments. Best for risk flags, exclusion lists, and any rule where multiple triggers should produce the same outcome.

๐ŸŸก XOR

Exactly one condition must be TRUE. Rarely needed but handy for toggle states or mutual-exclusion gates where one and only one input should fire.

๐ŸŸข NOT

Inverts a boolean result. Wrap around AND or OR to invert the whole gate. Often clearer than rewriting the condition with the opposite comparison.

๐Ÿ”ต IFS

Else-if chain โ€” cleaner than nested IFs for multi-bucket rules. Excel 2019, 2021, 365 and Excel for the web. Always include a final TRUE catch-all to avoid #N/A.

๐ŸŸฃ SWITCH

Match a single value against a list of cases. Reads like a lookup. Good for grade letters, size codes, status mapping, and short categorical conversions.

IF with ISBLANK and the empty-cell problem

Empty cells are tricky in Excel. A cell can look empty but actually contain a zero-length string returned by another formula. ISBLANK only catches the truly empty case. That distinction matters when you write summary formulas.

Strict empty check

=IF(ISBLANK(A2), "Missing", A2)

Returns "Missing" only when A2 is genuinely empty. If A2 holds ="", ISBLANK returns FALSE and you will get the empty string instead.

The looser "treat empty string as blank" check

=IF(A2="", "Missing", A2)

This one treats both truly empty cells and empty strings as missing. Most of the time, that is what you actually want, because formula-driven cells frequently produce "" as a "no value" output.

The "not blank" pattern

=IF(NOT(ISBLANK(A2)), A2*1.1, "")

Adds 10% to A2 only when A2 has a real value, otherwise leaves the result blank. Substitute A2<>"" for the looser check.

"Cell is not empty" with multiple inputs

For a row of inputs where all must be filled before calculating:

=IF(COUNTA(A2:C2)=3, A2+B2+C2, "Fill all fields")

COUNTA counts non-empty cells (including formula-driven empty strings as filled). Useful when you want to be permissive โ€” anything other than a truly empty cell counts.

Which empty-cell test fits?

๐Ÿ“‹ ISBLANK

Returns TRUE only for truly empty cells. Use this when you need to distinguish a never-touched cell from a formula that returned an empty string. ISBLANK is the strict option โ€” it ignores zero-length strings produced by other formulas, so a cell holding ="" reads as not blank even though it looks empty.

๐Ÿ“‹ Equals blank

Tests with =A2="". Returns TRUE for both genuinely empty cells AND for cells containing the empty string. This is the forgiving option and usually the right pick for everyday work, especially when your source column is populated by formulas that may return "" as a no-value placeholder.

๐Ÿ“‹ LEN check

Same outcome as the equals-blank test but more explicit. Some auditors prefer LEN(A2)=0 because the intent is unambiguous and it removes any confusion about whether you are testing for blank or for a specific string. Identical performance to ="" in modern Excel.

๐Ÿ“‹ COUNTA

Range-friendly. Use COUNTA when you want to confirm a whole block of cells is fully populated before running a calculation. =IF(COUNTA(A2:C2)=3, sum, "") gates the calc on all three inputs being filled. Treats formula-driven empty strings as populated.

IF with ISNUMBER and SEARCH: does a cell contain partial text?

One of the most common "I cannot make this work" questions: how do I check if a cell contains a substring, not equals it exactly? The native combo is ISNUMBER + SEARCH. SEARCH returns the position of the substring if found, or #VALUE! if not. ISNUMBER catches the position case as TRUE and the error as FALSE.

=IF(ISNUMBER(SEARCH("invoice", A2)), "Has invoice", "No")

SEARCH is case-insensitive. If you need case-sensitive, swap SEARCH for FIND. Same wrapping logic.

Contains any of several keywords

Use OR to widen the test:

=IF(OR(ISNUMBER(SEARCH("urgent", A2)), ISNUMBER(SEARCH("priority", A2))), "Flag", "")

Or, more elegantly with SUMPRODUCT for a list of terms in a separate range:

=IF(SUMPRODUCT(--ISNUMBER(SEARCH(D2:D5, A2)))>0, "Flag", "")

That second formula lets you maintain the keyword list in D2:D5 without touching the formula again.

Contains all of several keywords

Swap OR for AND and adjust the threshold:

=IF(SUMPRODUCT(--ISNUMBER(SEARCH(D2:D5, A2)))=COUNTA(D2:D5), "All present", "")
Take a free Excel practice quiz

Nested IF and IFS: writing else-if statements

When the answer depends on more than two outcomes, you have two paths: nested IFs or the newer IFS function. Both work. IFS is shorter and easier to read.

Nested IF (works in every Excel version)

Grade letter from a numeric score:

=IF(B2>=90, "A", IF(B2>=80, "B", IF(B2>=70, "C", IF(B2>=60, "D", "F"))))

Read it from the outside in. The first condition that matches wins; the rest never run. Modern Excel supports up to 64 levels of nesting, but anything past four or five gets painful to maintain.

IFS (Excel 2019, 2021, 365)

=IFS(B2>=90, "A", B2>=80, "B", B2>=70, "C", B2>=60, "D", TRUE, "F")

Pairs of test/result, evaluated top to bottom. The final TRUE, "F" acts as the catch-all default โ€” without it, scores below 60 would return #N/A.

SWITCH for exact matches

If you are matching a value to a list (not a range), SWITCH reads even cleaner:

=SWITCH(B2, "S", "Small", "M", "Medium", "L", "Large", "Other")

Before you ship that IF formula

Test with at least one TRUE input and one FALSE input to confirm both branches work
Check what happens when the source cell is blank or contains a formula-driven empty string
Check what happens when the source cell contains an error like #N/A or #DIV/0!
Confirm parentheses balance โ€” Excel highlights matched pairs as you type each one
If using IFS, always add a final TRUE/default pair to avoid an unmatched #N/A return
Wrap with IFERROR if the formula could divide by zero or hit #N/A from a lookup
Use absolute references ($A$1) for any anchor cells before dragging the formula down a column
Document with a cell comment or a header row note if the logic is non-obvious to the next reader
Copy the formula into a free cell with sample inputs to confirm the boolean test fires correctly
If the formula exceeds 80 characters or 3 nested IFs, consider IFS, SWITCH, or a lookup instead

IFERROR: catching #N/A, #VALUE!, and #DIV/0!

Errors in Excel propagate. One #N/A in column D ruins your SUM in row 200. IFERROR is the cleanest fix.

=IFERROR(VLOOKUP(A2, Sheet2!A:B, 2, FALSE), "Not found")

If the VLOOKUP fails, you get "Not found" instead of #N/A. Same idea with IF:

=IFERROR(IF(B2/C2>1, "Over", "Under"), 0)

If C2 is zero, the division throws #DIV/0! and IFERROR returns 0. Use IFNA if you only want to trap #N/A and let other errors surface โ€” useful during debugging.

IF combined with IFERROR for a lookup-with-default pattern

=IF(A2="", "", IFERROR(VLOOKUP(A2, table, 2, FALSE), "New entry"))

Three layers of safety: blank input returns blank, missing lookup returns a friendly label, real match returns the value. This is one of the most copy-pasted Excel patterns on the planet.

IFNA specifically for #N/A

If you want to trap only the "not found" case but let #DIV/0! or #VALUE! show up so you notice them:

=IFNA(VLOOKUP(A2, table, 2, FALSE), "Not in list")

Nested IF vs IFS

Pros

  • Nested IF works in every Excel version since 1980 โ€” full backward compatibility
  • Nested IF allows complex per-branch logic with different functions per IF level
  • IFS reads top-to-bottom like a decision table, much easier to audit at a glance
  • IFS avoids the trailing parenthesis pile-up that makes nested IFs hard to close
  • IFS arguments are clearly paired test/result, so adding new branches is straightforward

Cons

  • Nested IF gets hard to audit past 4 levels of nesting
  • Nested IF parentheses errors are easy to miss when the formula is long
  • IFS requires Excel 2019 or newer โ€” not available in older standalone installs
  • IFS returns #N/A if no condition matches and no TRUE default is set
  • Both functions can hide logic bugs that only surface with edge-case inputs

IF combined with AVERAGE and AVERAGEIF

Sometimes the value you return from an IF is not a label โ€” it is a calculation, often an average over a filtered range. Two patterns cover most cases.

Conditional average inside IF

If a region's name is "North," show the average of column C for North; otherwise blank:

=IF(A2="North", AVERAGEIF(A:A, "North", C:C), "")

AVERAGEIF does the heavy lifting. The IF just gates whether you show it.

AVERAGEIFS for multiple conditions

=AVERAGEIFS(C:C, A:A, "North", B:B, ">100")

Average of column C where column A equals "North" and column B is greater than 100. No IF wrapper needed โ€” AVERAGEIFS handles the conditions itself.

IF to choose which AVERAGE to run

=IF(D2="Region", AVERAGEIF(A:A, A2, C:C), AVERAGE(C:C))

Switches between a filtered average and the overall average based on a toggle cell. Handy in dashboard cells where the user can pick the scope.

Ignoring zeros in an average

AVERAGE includes zero values; if you want them excluded:

=AVERAGEIF(C:C, "<>0")

Or, for a hand-rolled version using IF as an array:

=AVERAGE(IF(C2:C100<>0, C2:C100))

In Excel 365 this works as-is; in older versions, confirm with Ctrl+Shift+Enter to make it an array formula.

Putting it together: a single working example

Let us stack several of these patterns. A sales report with this rule: pay a 5% bonus if quarterly revenue exceeds $10,000 AND error rate is below 2%, except if the territory is on the watchlist, in which case freeze the bonus. Show "Pending" if any input is blank:

=IF(OR(ISBLANK(A2), ISBLANK(B2), ISBLANK(C2)), "Pending",
  IF(C2="Watchlist", 0,
    IF(AND(A2>10000, B2<0.02), A2*0.05, 0)))

Three layers โ€” completeness check, watchlist override, then the AND test for the actual bonus. Wrap the whole thing in IFERROR if any of those inputs could be a formula that occasionally errors out.

Try another Excel practice test

Common mistakes that break IF formulas

A few patterns trip up everyone at some point. Worth scanning the list before debugging blind.

None of these are difficult once you have seen them; they are just the same handful of footguns every Excel user steps on at least once.

Working with IF across large datasets

The formulas above scale to a few hundred rows without thinking about it. Past that, two things change. First, you start to feel the recalculation cost โ€” every IF re-evaluates whenever any referenced cell changes. Second, copy-paste mistakes multiply, because a small wrong reference in row 2 propagates 50,000 times.

A few habits that keep large IF columns sane. Convert the data range to an Excel Table (Ctrl+T). Tables auto-fill formulas down and use structured references like [@Revenue] instead of B2, which makes the formula self-documenting and immune to insert/delete row shifts. If your IF compares against a config cell, name the cell (Formulas tab, Define Name) so the formula reads IF(B2>ThresholdRevenue, ...) instead of IF(B2>$G$1, ...). Future-you will thank present-you.

When the workbook gets slow

For really large sheets โ€” 100,000+ rows โ€” consider whether the IF needs to recalculate constantly. If the underlying data only changes when you import a new CSV, switch the workbook to Manual calculation mode (Formulas tab, Calculation Options). Excel will recalculate when you press F9, not on every keystroke.

When to stop using IF and switch to a different function

IF is a hammer. Most things look like nails. But a few situations call for a different tool entirely, and reaching for the right one upfront saves debugging hours later.

If you are counting how many cells meet a condition, COUNTIF or COUNTIFS replaces a long IF + SUM combo. Want to sum only matching values? SUMIF or SUMIFS. Looking up a value from a table? VLOOKUP, XLOOKUP, or INDEX/MATCH โ€” these read cleaner than nested IFs for lookups. Picking the Nth largest value with conditions? Use MAXIFS or MINIFS. Building a pivot-style summary across categories? An actual PivotTable usually beats a forest of IF formulas.

The general rule: if your IF formula is over 80 characters or contains more than three nested IFs, ask whether a dedicated function (or IFS, or SWITCH) would do the same job in fewer keystrokes. Shorter formulas are almost always easier to debug six months from now when you have forgotten exactly what you were trying to compute.

Excel Questions and Answers

How do I write an IF with two conditions in Excel?

Wrap your conditions in AND inside the IF test. Example: =IF(AND(B2>=70, C2>=80), "Pass", "Retake"). AND requires every condition to be true. Use OR instead if any single condition should trigger the result.

What is the difference between IF AND and IF OR?

AND returns TRUE only when every condition is true โ€” a strict gate. OR returns TRUE when at least one condition is true โ€” a loose match. You pick based on whether the rule is conjunctive ("both must hold") or disjunctive ("any will do").

How do I check if an Excel cell is blank inside an IF?

Use =IF(ISBLANK(A2), "Missing", A2) for a strict blank check, or =IF(A2="", "Missing", A2) for a looser check that also treats formula-driven empty strings as blank. The looser version is usually what you want in everyday work.

Can IF check for partial text in a cell?

Yes, combine ISNUMBER with SEARCH. Example: =IF(ISNUMBER(SEARCH("invoice", A2)), "Yes", "No"). SEARCH is case-insensitive; use FIND if you need case sensitivity. The ISNUMBER wrapper catches the position-or-error return from SEARCH.

How do I handle #N/A inside an IF formula?

Wrap the whole formula in IFERROR or IFNA. IFERROR catches any error type, while IFNA catches only #N/A. Example: =IFERROR(VLOOKUP(A2, table, 2, FALSE), "Not found"). This is the standard pattern for lookups with a friendly fallback.

What is the difference between nested IF and IFS?

Nested IF works in every Excel version and chains IF statements together. IFS (Excel 2019+) takes pairs of test/result and reads top-to-bottom like a decision table. IFS is shorter and easier to maintain, but lacks per-branch flexibility for complex logic.

How do I average values only when a condition is true?

Use AVERAGEIF or AVERAGEIFS directly โ€” no IF wrapper needed. Example: =AVERAGEIF(A:A, "North", C:C) averages column C only where column A is "North." Use AVERAGEIFS for multiple conditions: =AVERAGEIFS(C:C, A:A, "North", B:B, ">100").

Why does my IF formula return #VALUE!?

Usually one of three reasons: you are mixing text and numbers in a comparison, your formula references a cell containing an error that propagates, or you are using SEARCH/FIND without an ISNUMBER wrapper to catch the no-match error. Wrap with IFERROR to confirm whether an upstream error is the cause.
โ–ถ Start Quiz