Excel allows a user to use a logical expression in order to check if a condition is true. This is possible by using the **IF** function which returns Boolean TRUE or FALSE as a result. This step by step tutorial will assist all levels of Excel users in using the IF else function.

*Figure 1. The result of the IF function*

**Syntax of the IF Formula**

The generic formula for the IF function is:

**=IF(logical_test, value_if_true, value_if_false)**

The parameters of the IF function are:

**logical_test**– a logical expression that we want to check**value_if_true**– a value which the function returns if a logical_test is TRUE**value_if_false**– a value which the function returns if a logical_test is FALSE.

**Compare Two Numbers Using the IF Function**

In our example, we want to check if 5 is greater than 3. In case this is true, we return the message “5 is greater than 3”, and if it’s lower “5 is lower than 3”.

The formula looks like:

**=IF(5>3,"5 is greater than 3", "5 is lower than 3")**

The parameter **logical_test** is 5>3, as we want to check if 5 is greater than 3. The **value_if_true** is “5 is greater than 3”, while the **value_if_false** is “5 is lower than 3”.

To apply the IF function, we need to follow these steps:

- Select cell B3 and click on it
- Insert the formula:
`=IF(5>3,"5 is greater than 3", "5 is lower than 3")`

- Press enter

* Figure 2. Using the IF function to compare two numbers*

The logical_test 5>3 is TRUE, so the IF function returns value_if_true. Therefore, the result in the cell B3 is “5 is greater than 3”.

**Using the IF Function to Compare Two Cells**

In this example, we will provide cells references to the function, instead of numbers. The example is similar, but now we put 7 in B3 and 12 in C3. The **logical_test** is now B3>C3. The **value_if_true** is “B3 is greater than C3”, while the **value_if_false** is “B3 is lower than C3”. In the cell D3, we want to get the result.

The formula is:

**=IF(B3>C3,"B3 is greater than C3", "B3 is lower than C3")**

To apply the IF function, we need to follow these steps:

- Select cell D3 and click on it
- Insert the formula:
`=IF(B3>C3,"B3 is greater than C3", "B3 is lower than C3")`

- Press enter

*Figure 3. Using the IF function to compare two cells*

Now the logical condition is FALSE since 7 is not greater than 12. Therefore, the result in the cell B3 is “B3 is lower than C3”.

Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.

**Are you still looking for help with the IF function? View our comprehensive round-up of IF function tutorials here.**

## Leave a Comment