Create conditional formulas by using the IF function

Microsoft Office Excel 2003

Use the AND, OR, and NOT functions, and operators to do this task.

Worksheet example

The example may be easier to understand if you copy it to a blank worksheet.

Show How?

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic. Do not select the row or column headers.

    Selecting an example from Help

    Selecting an example from Help

  3. Press CTRL+C.
  4. In the worksheet, select cell A1, and press CTRL+V.
  5. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and then click Formula Auditing Mode.
 
1
2
3
4
A
Data
15
9
8
Formula Description (Result)
=AND(A2>A3, A2<A4) Is 15 greater than 9 and less than 8? (FALSE)
=OR(A2>A3, A2<A4) Is 15 greater than 9 or less than 8? (TRUE)
=NOT(A2+A3=24) Is 15 plus 9 not equal to 24? (FALSE)

Function details

AND

OR

NOT

ShowFor a result is another calculation, or any other value other than TRUE or FALSE.

Use the IF, AND, and OR functions to do this task.

Worksheet example

The example may be easier to understand if you copy it to a blank worksheet.

ShowHow?

  1. Create a blank workbook or worksheet.
  2. Select the example in the Help topic. Do not select the row or column headers.

    Selecting an example from Help

    Selecting an example from Help

  3. Press CTRL+C.
  4. In the worksheet, select cell A1, and press CTRL+V.
  5. To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Tools menu, point to Formula Auditing, and then click Formula Auditing Mode.
 
1
2
3
4
A
Data
15
9
8
Formula Description (Result)
=IF(A2=15, "OK", "Not OK") If the value in cell A2 equals 15, then return "OK". (OK)
=IF(AND(A2>A3, A2<A4), "OK", "Not OK") If 15 is greater than 9 and less than 8, then return "OK". (Not OK)
=IF(OR(A2>A3, A2<A4), "OK", "Not OK") If 15 is greater than 9 or less than 8, then return "OK". (OK)

The IF function uses the following arguments.

Formula with the IF function

Formula with the IF function

Callout 1 logical_test: the condition you want to check

Callout 2 value_if_true: the value to return if the condition is true

Callout 3 value_if_false: the value to return if the condition is false

Function details

AND

OR

IF