Creating Formulas Using the If Function

The IF logical function will return one value if a condition is true and another value if the condition is false. Use the IF function when you want to compare two items in your workbook. The IF function looks like this:
=IF(logical_test,value_if_true,
value_if_false)

To use the IF Function:

  1. Select the cell in which you want to enter the function.
  2. Click the Insert Function button.
  3. Click IF from the list of Logical functions and click OK.
  4. Enter the Logical_test argument. This argument states the condition you want to test for. Use cell references and/or values with logical operators. For example, B5<D7 will return true if B5 is less than D7 and false if B5 is not less than D7.
  5. Enter the value_if_true argument. This is the text string or value that will be displayed if the Logical_test argument is true.
  6. Enter the value_if_false argument. This is the text string or value that will be displayed if the Logical_test argument is false.
  7. Click OK.


  • If the IF function is not in your list of most recently used functions, click the arrow next to the Or select a category: box, click Logical, and select IF from that list of functions.
  • When you click an argument box, a description of the argument appears below the description of the function. Also, as you enter arguments, the dialog box will display the results of your formula.

Logical operators are used to compare numbers in two or more cells to a constant. The logical operators for the IF function are:

=      Equal to
<      Less than
>      Greater than
≤      Less than or equal to
≥      Greater than or equal to
≠       Not equal to
NOT   Logical Not
AND   Logical And
OR     Logical Or

To open the Insert Function box, you can also:

  • Select Function... from the Insert menu.

    OR

  • Click the arrow next to the AutoSum toolbar button and select More Functions...