Excel If Function
If Function in Excel
The IF function or IF statement in Excel is composed of three parts separated by commas.
- Condition
- What to display if the condition is true
- What to display if the condition is false
See in below image how to display pass and fail student if marks is greater than 400 it display pass otherwise fail.

How to Create If Function in Excel
To create If function in excel follow below steps;
- Type the code in the cell: =if(
- Type the condition with comma: C7>70,
- Type what you want to show if condition is true. Here we display Pass if condition is true
- Type a comma: ,
- Type what you want to show if condition is false. Here we display Fail if condition is false
- Then close the bracket and press the Enter key.
- Final function look like this =IF(C7>400,"Pass","Fail")
If Condition Apply on Cell
Some time we need to print specific cell value based on condition,use below syntax.
Syntax
=IF(logical_test, value_if_true, value_if_false)
Where, the 'logical_test', 'value_if_true', and 'value_if_false' are the three parts or arguments in the IF function.
Based on the above syntax, the general format of the Excel IF function is defined as below:
Syntax
=IF(A1>B2, "TRUE", "FALSE")
Arguments of IF Function
The IF Formula in Excel accepts the following three arguments:
- Logical_test: It is the first and the mandatory argument. It helps us specify the condition to be tested or evaluated as either TRUE or FALSE. The specified condition can be a value or a logical expression.
- Value_if_true: It is an optional argument accepted by the IF function. It helps us specify the value that we need to return as output when the given condition (logical_test) is 'TRUE'.
- Value_if_false: It is another optional argument accepted by the IF function. It helps us specify the value that we need to return as output when the given condition (logical_test) is 'FALSE'.
Syntax
=IF(C7>10,A1,A1+10)
Using above syntax we print value of cell A1 if condition is true otherwise print cell A1+10
Logical Operators used in IF function
The Excel IF formula typically uses logical operators to compare the values based on the given condition. When evaluating a test using the IF function, we can use any of the below logical operators:
Operator | Description | Example |
---|---|---|
= | Equal to | A1=B1 |
< | Less than | A1 |
<= | Less than or equal to | A1<=B1 |
> | Greater than | A1>B1 |
>= | Greater than or equal to | A1>=B1 |
<> | Not equal to | A1<>B1 |
How to use the IF Function in Excel?
To use the IF function in our Excel sheet, we must perform the following steps:
- First, we must enter or type the equal sign (=) to start the function name.
- Next, we must type the function name, followed by the starting bracket, i.e., =IF(.
- In the next step, we need to give the function the first argument (logical_test). We must specify the condition using operators' signs for logical comparison.
- After that, we need to give optional arguments, returning a value as an output based on the TRUE or FALSE.