The IF function performs a logical test (specified from its first argument), and returns either one of its second or third argument depending on the result of the test. If the test returns TRUE, the result will be the second argument, otherwise it will be the third. In this guide, we’re going to show you how to use the IF function along with some tips and error handling methods.

Supported versions

  • All Excel versions


IF(logical_test, value_if_true, [value_if_false])


logical_test The logical statement you want to test
value_if_true Return value if the result of logical_test is TRUE
[value_if_false] Optional. Return value if the result of logical_test is FALSE



Example 1

 formula checks the value of the cell E3. If the value is equal or greater than 300 then the formula returns a "Yes" string. Otherwise, the formula will print "No" as a result.

IF Example 1

Example 2

formula is an example for Nested-IF functions. The Nested-IF structure allows testing multiple conditions in a single formula. Each new condition is placed into the parent IF function's third argument, which represents the FALSE return value. As a result, the formula passes the next IF function if the result of a logical test is FALSE.

Our formula checks the B3 cell. The first check is to determine whether the value of the cell is less than or equal to 151. If it is, the formula returns "I" string. If it not, it continues with the second IF function. The second function checks if the value is less than or equal to 251. Although a number less than 151 is also less than 251, the formula eliminates numbers less than 151 in the first step. The order of conditions is important.

IF Example 2

Download Workbook


  • Operators
    Operator Description Criteria Sample Criteria Meaning
    = Equal to “=10000” Equal to 10000
    <> Not equal to “<>10000” Not equal to 10000
    > Greater than “>10000” Greater than 10000
    < Less than “>10000” Less than 10000
    >= Greater than or equal to “>=10000” Greater than or equal to 10000
    <= Less than or equal to “<=10000” Less than or equal to 10000
  • A Nested-IF structure can include up to 64 IF statements.



You will get 0 as a result when either value_if_true or value_if_False argument is empty.