Free Excel Formula Course / Lesson 2 of 10

Excel Logical Formulas and Error Handling

Make decisions from data, combine tests, return readable messages, and handle missing or invalid values without hiding useful errors.

Lesson 2: Turn conditions into decisions

Logical functions return TRUE or FALSE, or choose a result based on a test. In the examples, A2 contains a score and B2 contains an order status.

Example: if A2 is 82, =IF(A2>=70,"Pass","Retry") returns Pass. Text results need quotation marks.

Logical and error formulas

Use exact comparisons and explicit fallback results. IFERROR catches every error, so reserve it for cases where a friendly fallback is meaningful; IFNA catches only #N/A.

FunctionWhat it returnsExample
IFOne result when a test is true, another when false.=IF(A2>=70,"Pass","Retry")
IFSFirst result whose condition is true.=IFS(A2>=90,"A",A2>=80,"B",TRUE,"C")
ANDTRUE only when every test is true.=AND(A2>=70,B2="Paid")
ORTRUE when at least one test is true.=OR(B2="New",B2="Priority")
NOTReverses TRUE/FALSE.=NOT(A2="Closed")
XORTRUE when an odd number of tests are true.=XOR(A2>0,B2>0)
SWITCHMatches one expression to listed values.=SWITCH(C2,"S","Small","M","Medium","Other")
IFERRORReplaces any formula error with a chosen result.=IFERROR(A2/B2,0)
IFNAReplaces #N/A only.=IFNA(XLOOKUP(E2,A:A,B:B),"Not found")
ISBLANKTests whether a cell is truly empty.=IF(ISBLANK(A2),"Missing","Entered")
ISNUMBERTests whether a value is numeric.=ISNUMBER(A2)
ISTEXTTests whether a value is text.=ISTEXT(A2)
ISNONTEXTTRUE for non-text values, including blanks.=ISNONTEXT(A2)
ISLOGICALTests for TRUE or FALSE.=ISLOGICAL(A2)
ISERRORTests for any Excel error value.=ISERROR(A2)
ISERRTests for errors other than #N/A.=ISERR(A2)
ISNATests specifically for #N/A.=ISNA(A2)
ERROR.TYPEReturns a number identifying an error type.=IFERROR(ERROR.TYPE(A2),0)
TRUE / FALSEReturn the logical values TRUE and FALSE.=TRUE() returns TRUE.

Copy a safe division pattern: =IFERROR(A2/B2,0)

Nested decisions and good error messages

Prefer IFS or SWITCH when many branches make nested IF difficult to audit. Use a deliberate final condition so unmatched values do not silently receive the wrong category.

  1. Test blank inputs before doing arithmetic.
  2. Return a meaningful label such as "Check quantity" instead of masking every problem as zero.
  3. Use IFNA for a lookup miss and let other errors remain visible during development.

Progress stays in this browser.