|
|
|
This page presents how to work with Microsoft Excel 2007 features and its redesigned interface. You may also visit our Excel Question page.
|
Create conditional formulas

Tags calculation; conditional; conditional formatting; equation; formula; IF function

What are tags?
Testing whether conditions are true or false and making logical comparisons between expressions (expression: A combination of operators, field names, functions, literals, and constants that evaluates to a single value. Expressions can specify criteria (such as Order Amount>10000) or perform calculations on field values (such as Price*Quantity).) 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 (argument: The values that a function uses to perform operations or calculations. The type of argument a function uses is specific to the function. Common arguments that are used within functions include numbers, text, cell references, and names.).


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)
Create a conditional formula that results in another calculation or in values other than TRUE or FALSE

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 (operator: A sign or symbol that specifies the type of calculation to perform within an expression. There are mathematical, comparison, logical, and reference 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.
|
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
|
A
|
B
|
|
Data
|
|
|
15
|
|
|
9
|
|
|
8
|
|
|
Sprockets
|
|
|
Widgets
|
|
|
Formula
|
Description (Result)
|
|
=AND(A2>A3, A2<A4)
|
Determines if the value in cell A2 is greater than the value in A3 and also if the value in A2 is less than the value in A4. (FALSE)
|
|
=OR(A2>A3, A2<A4)
|
Determines if the value in cell A2 is greater than the value in A3 or if the value in A2 is less than the value in A4. (TRUE)
|
|
=NOT(A2+A3=24)
|
Determines if the sum of the values in cells A2 and A3 is not equal to 24. (FALSE)
|
|
=NOT(A5="Sprockets")
|
Determines if the value in cell A5 is not equal to "Sprockets." (FALSE)
|
|
=OR(A5<>"Sprockets",A6 = "Widgets")
|
Determines if the value in cell A5 is not equal to "Sprockets" or if the value in A6 is equal to "Widgets." (TRUE)
|
|
For more information about how to use these functions, see AND function, OR function, and NOT function.
Top of Page
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.
|
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
|
A
|
B
|
|
Data
|
|
|
15
|
|
|
9
|
|
|
8
|
|
|
Sprockets
|
|
|
Widgets
|
|
|
Formula
|
Description (Result)
|
|
=IF(A2=15, "OK", "Not OK")
|
If the value in cell A2 equals 15, return "OK." Otherwise, return "Not OK." (OK)
|
|
=IF(A2<>15, "OK", "Not OK")
|
If the value in cell A2 is not equal to 15, return "OK." Otherwise, return "Not OK." (Not OK)
|
|
=IF(NOT(A2<=15), "OK", "Not OK")
|
If the value in cell A2 is not less than or equal to 15, return "OK." Otherwise, return "Not OK." (Not OK)
|
|
=IF(A5<>"SPROCKETS", "OK", "Not OK")
|
If the value in cell A5 is not equal to "SPROCKETS", return "OK." Otherwise, return "Not OK." (Not OK)
|
|
=IF(AND(A2>A3, A2<A4), "OK", "Not OK")
|
If the value in cell A2 is greater than the value in A3 and the value in A2 is also less than the value in A4, return "OK." Otherwise, return "Not OK." (Not OK)
|
|
=IF(AND(A2<>A3, A2<>A4), "OK", "Not OK")
|
If the value in cell A2 is not equal to A3 and the value in A2 is also not equal to the value in A4, return "OK." Otherwise, return "Not OK." (OK)
|
|
=IF(OR(A2>A3, A2<A4), "OK", "Not OK")
|
If the value in cell A2 is greater than the value in A3 or the value in A2 is less than the value in A4, return "OK." Otherwise, return "Not OK." (OK)
|
|
=IF(OR(A5<>"Sprockets", A6<>"Widgets"), "OK", "Not OK")
|
If the value in cell A5 is not equal to "Sprockets" or the value in A6 is not equal to "Widgets", return "OK." Otherwise, return "Not OK." (Not OK)
|
|
=IF(OR(A2<>A3, A2<>A4), "OK", "Not OK")
|
If the value in cell A2 is not equal to the value in A3 or the value in A2 is not equal to the value in A4, return "OK." Otherwise, return "Not OK." (OK)
|
|
For more information about how to use these functions, see IF function, AND function, and OR function.
Top of Page