Logical Functions - IF

"If you alone can keep your head......."

Essential to all programming languages and one of the most powerful functions in Excel is the =IF function:

It gives your spreadsheet the ability to make decisions.

The format is: =IF(Test Condition, True Result, False Result)
As you can see there are three arguments

Lets look at some examples:

Example 1- a basic IF statement
In cell C3 type =IF(A1 > 10, 100, 0)

if

The Test condition is A1 > 10.
If it is True THEN put 100 into cell C3.
ELSE put 0 into cell C3.

Now try entering different values in cell A1 and observe the values in C3

Example 2 - Outputing Strings
=IF(A1 >=5000,"Pay a Bonus","Pay no Bonus")
In this example, text is placed into the cell instead of a value.

Example 3
=IF(A1 >=5000, A1*.02, 0)
In this example, a calculated value is displayed.
Explanation: If A1 contains a number greater than or equal to 5000 calculate a bonus of 2% of A1 otherwise pay no bonus.