The Excel IF function performs a logical test and returns one value for a TRUE result, and another for a FALSE result. It can also be combined with logical functions like AND and OR functions and more than one condition can be tested by nesting many IF functions together. The IF function can also be used to check if cell equals in Excel.

**Formula**

`=`

**IF(check_string,true_result,false_result)**

**Explanation**

The formula incorporating Excel IF function to check if cell equals use the following arguments:

**check_string**(required): This is the logical test bit in the formula. The IF function will return TRUE if the value in a particular cell is the same or it will return FALSE.**true_result**: This is what is displayed if the IF function returns a true value. If nothing is specified it will simply display TRUE.**false_result**: This is what is displayed if the IF function returns a false value. If nothing is specified it will simply display FALSE.

This works as follows:

- The IF function will test for the logical test bit in the formula. The IF function will return TRUE if the value in a particular cell is the same or it will return FALSE.
- As per the parameters for true_result and false_result, the operations will be carried out.

**Example** 1

In this example, we just want to highlight records where the color is ‘Blue’. Or in other words, we want to check the cells in column B, and then take an action if they contain the word “Blue”. To check if cell equals, the following formula is used using Excel IF function;

`=`

**IF(B6=“Blue”,“YES”,“NO”)**

This works as follows:

- The IF function will test for the logical test bit in the formula which is if the string is “Blue”.
- If it is, it will return “YES”. If not then a “NO” will be printed.

* Figure 1. Example of IF function to check if Cell Equals 1*

**Example 2**

With the Excel IF function, you can do something even more. For example, suppose you want to double the price of Blue items in the above example. In such a case, you can also use this formula in column D to calculate the new price;

`=`

`IF(B9=“Blue”,C9*2,C9)`

This works as follows:

- The Excel IF function will test for the logical test bit in the formula which is if the string is “Blue”.
**If the result comes out to be TRUE, we double the original price**.- If the result comes out to be FALSE, we just use the original price as it is.

*Figure 2. Example of IF function to check if Cell Equals 2*

## Leave a Comment