Testing whether conditions are true or false and making logical comparisons between expressions are common to many tasks. You can use the AND, OR, NOT, and IF functions to create conditional formulas.
For example, the IF function uses the following arguments.
Formula that uses the IF function
logical_test: The condition that you want to check.
value_if_true: The value to return if the condition is True.
value_if_false: The value to return if the condition is False.
For more information about how to create formulas, see Create or delete a formula.
What do you want to do?
Create a conditional formula that results in a logical value (TRUE or FALSE)
To do this task, use the AND, OR, and NOT functions and operators as shown in the following example.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How do I copy an example?

Select the example in this article.
Selecting an example from Help

Press CTRL+C.

In Excel, create a blank workbook or worksheet.

In the worksheet, select cell A1, and press CTRL+V.
Important: For the example to work properly, you must paste it into cell A1 of the worksheet.

To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.
After you copy the example to a blank worksheet, you can adapt it to suit your needs.

For more information about how to use these functions, see AND function, OR function, and NOT function.
Create a conditional formula that results in another calculation or in values other than TRUE or FALSE
To do this task, use the IF, AND, and OR functions and operators as shown in the following example.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How do I copy an example?

Select the example in this article.
Important: Do not select the row or column headers.
Selecting an example from Help

Press CTRL+C.

In Excel, create a blank workbook or worksheet.

In the worksheet, select cell A1, and press CTRL+V.
Important: For the example to work properly, you must paste it into cell A1 of the worksheet.

To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.
After you copy the example to a blank worksheet, you can adapt it to suit your needs.

For more information about how to use these functions, see IF function, AND function, and OR function.