IF function in Excel checks whether a condition is met and if it’s (TRUE) it returns a value, and another value if the condition does not meets (FALSE). IF function gives excel formula a decision- making capabilities. This function takes three arguments, each separated by a comma.

**Excel IF Function (Table of Contents)**

## IF Function in Excel

If excel function is a very useful and most widely used conditional function in excel, this function is used to give a result based on certain criteria for example if condition A is met then value should be B and if the condition is not met the value should be C, this function takes three arguments, the first argument is the criteria while the second argument is the result when the condition is true and third argument is when the condition is false.

### IF Formula in Excel with Example

**Recommended Courses**

### How to Use IF Function in Excel

IF Function in Excel is very simple and easy to use. Let’s understands the use of IF Function in Excel also with the example of excel IF function

### Excel IF Else Example #1

Let us discuss an example of excel IF function.

If there would be no oxygen on a planet then there will be no life and there will be oxygen then there will be a life on a planet.

We have to find out whether there is a life possible on the planets given in the list, the condition is there has to be an availability of oxygen, in column B, we have specified whether there is a oxygen on a given planet or not.

So, using IF function we will find out whether a life is possible or not on the planet

So, applying If formula in C2,

**=if(B2=” Yes”, “Life is Possible”, “Life is Not Possible”)**

Dragging the IF formula down, we find out that Life is possible on Earth only because there is an availability of oxygen.

### Flow Chart of IF Function

**1st Case:**

Similarly, there will be the same flow for IF condition for the 2nd and 3rd case.

**4th Case:**

So, you can see the IF function in Excel, allows us to make logical comparisons between values. The *modus* *operandi* of IF is if something is true, then do something, otherwise do something else.

### Excel IF Else Example #2

In this example of excel IF function, if we have a list of years and we want to find out the given year is a leap year or not.

A leap year is a year that has 366 days (the extra day is the 29th of February). The condition to check a year is a leap year or not, the year has to be exactly divisible by 4 and at the same not exactly divisible by 100, then it is a leap year or if the year is exactly divisible by 400, then it is a leap year.

So, to find the remainder after a number is divided by a divisor we use MOD function in excel.

So, if MOD(Year,4)=0 and MOD(Year,100)<>(is not equal to) 0, then it is a leap year

Or if MOD(Year,400)=0, then also it a leap year, otherwise it is not a leap year

So, in excel the formula to find the leap year would be

**=IF(OR(AND((MOD(Year,4)=0),(MOD(Year,100)<>0)),(MOD(Year,400)=0)),”Leap Year”,”Not A Leap Year”)**

Where Year is a reference value

So, after applying the If the formula in Excel, we get the list of years that are a leap year, 1960, 2028 and 2148 in the list are the leap year.

So, in the above case we have used IF Functionin excel, AND, OR and MOD function to find the leap year. AND used when two conditions are to be checked as TRUE and OR if either of the condition is to be checked as TRUE.

### Excel IF Else Example #3

In this example of excel IF function, logical Operators and their meaning that is used in IF function in Excel to test conditions are:

Another example of excel IF function, if there is a list of Driver and there a road intersection, right turns goes to Town B and left turn goes to Town C and we want to find, drivers have their destinations to Town B and Town C.

Again, we will use IF function in excel to find the destination, according to the condition if a driver makes right turns he/she reaches Town B and if he/she makes a left turn he/she reaches Town C.

So, the IF formula in Excel would be

**=if(B2=”Left”, “Town C”, “Town B”)**

Dragging formula down we get the destinations of each driver for the turning movement taken.

**Output:**

Total 6 Drivers have reached Town C and remaining that is 4 have reached Town B.

### Excel IF Vlookup Example #4

In this example of excel IF function, we will be using the excel IF Vlookup function. We have an inventory that contains a list of item and number of the items

Name of items are listed in column A and the number of items in column B and in E2 we have the data validation list containing the entire items list. Now, we want to check whether an item is available in the inventory or not.

To check that we will use the vlookup along with the IF function, a vlookup function will look up the number of item value and IF function will check whether the item number is greater than zero or not.

So, in F2 we will use the If formula in excel

**=IF(VLOOKUP(E2,A2:B11,2,0)=0,”Item Not Available”,”Item Available”)**

If the lookup value of an item is equal to 0 then Item is not available else the item is available.

If we select any other item in E2 item list, we can know whether the item is available or not in the inventory.

**Nested IF:**

When IF function is used inside another IF formula in excel, this is known as the Nesting of IF function. If there are multiple conditions that need to be fulfilled, in that case, we have to use the Nested IF.

Nesting of IF function syntactically could be written as

**IF( condition1, value_if_true1, IF( condition2, value_if_true2, value_if_false2 ))**

### Excel IF Function Example #5

In this example of excel IF function, We have a list of students and their marks, and we have the grade criteria depending upon the marks obtained by the student and we have to find the grade of each student.

We will use the If conditions to find the grade of the student, we will be using the Nested IF that is if inside IF conditions since we have multiple criteria to decide the grade of each student.

We will use multiple IF conditions with AND function we find out the grade, the formula will be

**=IF((B2>=95),”A”,IF(AND(B2>=85,B2<=94),”B”,IF(AND(B2>=75,B2<=84),”C”,IF(AND(B2>=61,B2<=74),”D”,”F”))))**

We know, IF function checks the logical condition

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

Let’s break this and check,

- 1
^{st}logical test is B2>=95 - Value_if_true execute: “A” (Grade A)
- else(comma) enter value_if_false
- value_if_false – again finds another IF condition and enter IF condition
- 2
^{nd}Logical Test is B2>=85(logical expression 1) and B2<=94(logical expression 2), since we are testing both the conditions has to be TRUE, and we have used AND to check the multiple logical expression - Value_if_true execute: “B” (Grade B)
- else(comma) enter value_if_false
- value_if_false – again finds another IF condition and enter IF condition
- 3
^{rd}Logical Test is B2>=75(logical expression 1) and B2<=84(logical expression 2), since we are testing both the conditions has to be TRUE, and we have used AND to check the multiple logical expression - Value_if_true execute: “C” (Grade C)
- else(comma) enter value_if_false
- value_if_false – again finds another IF condition and enter IF condition
- 4
^{th}Logical Test is B2>=61(logical expression 1) and B2<=74(logical expression 2), since we are testing both the conditions has to be TRUE, and we have used AND to check the multiple logical expression - Value_if_true execute: “D” (Grade D)
- else(comma) enter value_if_false
- value_if_false execute: “F” (Grade F)
- Closing Parenthesis

** **

**Things to Remember About If Function in Excel**

- Use Nesting if function to a limited extent because multiple if statements require a great deal of thought to build them accurately.
- Whenever we use multiple IF statements, it requires multiple open and closing parentheses (), which often becomes difficult to manage. Excel provides a best way to deal with this situation, check for the color of the each opening and closing parenthesis, the last closing parenthesis color would always be black, that denotes the formula statement ends there.
- Whenever we pass a string value, for value_if_true and value_if_false argument, or we test a reference against a string value, that always has to be in double quotes, simply passing a string value without quotes would result in #NAME? error

### IF Excel Function Video

### Recommended Articles

This has been a guide to IF Function in Excel. Here we discuss the If Formula in excel with example and how to use IF function along with Example of If Function and downloadable excel templates. You may also look at these useful functions in excel

- What is Logical Test in Excel?
- “Not Equal to” in Excel Formula
- How to use IFERROR in Excel?
- Data Validation Excel
- MODE Function
- EXACT Function
- AND Function
- LOOKUP Excel Function
- RAND Excel Function
- True Excel
- VLOOKUP Excel
- AND in Excel
- IFERROR Excel

- 35+ Courses
- 120+ Hours
- Full Lifetime Access
- Certificate of Completion