Excel IF Function

The IF function lets a cell display one value when a condition is true and a different value when it is false, forming the basis of decision-making in Excel formulas.

The Structure of IF

IF takes three arguments: IF(logical_test, value_if_true, value_if_false). The logical_test is any expression that evaluates to TRUE or FALSE, such as a comparison between a cell and a number. Excel returns the second argument when the test is true and the third argument when it is false.

Example

=IF(A1>50,"Pass","Fail")

Comparison Operators Used in Logical Tests

OperatorMeaning
=Equal to
<>Not equal to
>Greater than
<Less than
>=Greater than or equal to
<=Less than or equal to

Nesting IF for More Than Two Outcomes

A single IF only chooses between two results. To handle several possible outcomes, such as assigning a letter grade, place another IF inside the value_if_false argument. Excel checks each condition in order and stops at the first one that is true.

Example

=IF(A1>=90,"A",IF(A1>=80,"B",IF(A1>=70,"C","F")))
Note: Nested IFs become hard to read and easy to miscount once you go past two or three levels. For long grading scales or tiered lookups, a lookup table with VLOOKUP or XLOOKUP, or the newer IFS function, is usually clearer.

Combining IF with AND and OR

The logical_test argument can itself be an AND or OR function when a decision depends on more than one condition. AND requires every condition to be true, while OR only needs one of them to be true.

  • =IF(AND(A1>=60,B1="Yes"),"Eligible","Not Eligible") requires both conditions to hold.
  • =IF(OR(A1="Manager",A1="Director"),"Approved","Needs Review") passes if either title matches.
  • Conditions can mix text comparisons, numeric comparisons, and even other functions.
Note: In Excel 2019, Excel 2021, and Microsoft 365, the IFS function lets you list several condition-result pairs in one formula, avoiding deeply nested parentheses: =IFS(A1>=90,"A",A1>=80,"B",TRUE,"F").