## How to use the IF function

*Article updated on February 15, 2018*

The IF function returns one value if the logical test is TRUE and another value if the logical test is FALSE.

**Excel function syntax**

IF(*logical_test*, [*value_if_true*], [*value_if_false*])

### Arguments

logical_test |
Required. The logical expression determines what value the IF function returns. Excel evaluates all numerical values positive or negative to TRUE except 0 (zero) that equals FALSE. |

[value_if_true] |
Optional. The value the IF function returns if the logical expression evaluates to TRUE. If omitted 0 (zero) is returned. |

[value_if_false] |
Optional. The value the IF function returns if the logical expression evaluates to FALSE. If omitted 0 (zero) is returned. |

### Logical operators

These characters allow you to do more advanced comparisons than the equal sign.

= (equal sign)

< less than

> greater than

<= less than or equal to

>= greater than or equal to

<> not equal

### Use an Excel function to perform a logical test

The picture above shows a formula in cell range C3 that tests if cell B3 is blank. It is not blank so it returns FALSE, however, cell B4 is blank so the IF function returns TRUE in cell C4.

In cell C5 the IF function tests if a cell value is a number. Cell B6 has a number and cell B7 has a text value.

Cell C7 tests if B7 contains a formula.

### Download excel *.xlsx file

### Articles with the 'IF' Function

The following 17 articles have formulas that contain the IF function.

Extract unique distinct values from a multi-column cell range

Question: I have cell values spanning over several columns and I want to create a unique list from that range. […]### Functions in 'Logical'

The IF function function is one of many functions in the 'Logical' category.

### 13 Responses to “How to use the IF function”

### Leave a Reply

**How to add a formula to your comment:**

<code>your formula</code>

Remember to convert less than and larger than signs to html character entities before you post your comment.

**How to add VBA code to your comment:**

[vb 1="vbnet" language=","]

VBA code

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org

Add picture link to comment.

**Contact Oscar**

You can contact me through this webpage

[...] Interested in how the IF function works, read this post: IF function explained [...]

[…] IF(logical_test;[value_if:true];[value_if_false]) Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE […]

[…] IF(logical_test,[value_if_true],[value_if_false]) Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE […]

[…] IF(logical_test, [value_if_true],[value_if_false]) Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE […]

[…] IF(logical_test,[value_if:true], [value_if_false]) Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE […]

Hi Oscar

Thank you for your explanation and examples. I'd really appreciate it if you could you help me with this:

I'm trying to say, "if a cell from E2 to E89 contains 1, then sum the contents of the corresponding cell in D", ie. I only want to add D cell contents together if the corresponding E cell contains '1'.

=SUM(IF(E2:E89=1, D2:D89, 0))

Thank you!

Alison.

[…] If function […]

[…] want to sort text values only, the IF and ISTEXT functions check if a value is a text […]

[…] If the value in cell K23 is larger than cell K24 AND cell K24 is smaller than K25 THEN return the closing price. If not return nothing. Read more about IF function. […]

[…] IF(logical_test, [value_if_true], [value_if_false]) Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE […]

[…] IF(logical_test, [value_if_true], [value_if_false]) Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE […]

[…] IF(logical_test;[value_if:true];[value_if_false]) Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE […]

[…] IF(logical_test,[value_if:true];[value_if_false]) Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE […]