​​​​If

If the given condition is met, the cell will be filled with the value given as the second argument. In other cases, the cell will be filled with the value given as the third argument.

If syntax

=IF(Logical test, Value if true, Value if false)

Argument  Argument description
1Logical test The condition that is checked to be True or False.
2Value if TrueThe output that will be returned by Excel if the logical test is True.
3Value if False The output that will be returned by Excel if the logical test is False.

Try it for yourself

Take a look at the formulas in cells C2:C5 and try to do it yourself in cell C6.

Explanation

If the score of a student is higher than 60, the function returns the value for True, which is ‘Pass’. If the value is lower than 60 or equal to 60, it will return the value for False, which is ‘Fail’.

Certainly the best way to understand what a condition is and how they can be useful is by looking at some examples.

Questions

What type of conditions are there?

The most often used way of creating conditions is by combining any sort of data (numbers, text, dates, etc) with a comparison operator. For example:

1. 5 < 6, 5 is indeed less than 6, so True.

2. 10 < 8, 10 is not less than 8, it is greater than 8, so this is False.

3. "Textual data1" = "Textual data2", the two texts are not the same, therefore the statement is False.

4. 1-1-2000 <> 2-1-2000, the dates are unequal, which is exactly what the operator says, so the statement is True.

Here’s an overview of the operators you can use to form conditions:

Operator Meaning
=Equal to
<>NOT equal to
>Greater than
<Less than
>=Greater than or equal to
<=Less than or equal to

However, conditions do not have to be from comparison operators, there are other functions that evaluate to True or False that can be used as a condition. For example:

=IF(ISBLANK(A1), "A1 is blank", "A1 is not blank") 

You can see this one in action down at the examples.

Can If functions be nested?

Yes they can. The second and third argument of an if function can, in turn, be if functions themselves. And if the result is True or False, even the first argument can be an if function. You can see an example of this in our Complete Guide on If.

What does a ‘0’ in the cell mean?

You probably did not fill in the second or third argument of the function. Add arguments two and three.

What does ‘#NAME?’ in the cell mean?

This means that the formula name was not recognized. It was probably misspelled. Make sure the function name is spelled correctly and try again.

If examples

Using functions as condition

Instead of regular conditions, you can also use functions that evaluate to True or False as conditions for an If function. In this example the ISBLANK function is used as a condition. ISBLANK is True when the cell is empty and False when the cell is not.

Try typing anything in cell A1 to see B1 change.

__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"36c04":{"name":"Main Accent","parent":-1},"3a8fd":{"name":"Accent Light","parent":"36c04","lock":{"saturation":1,"lightness":1}}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"36c04":{"val":"rgb(255, 204, 102)","hsl":{"h":40,"s":1,"l":0.7}},"3a8fd":{"val":"rgb(241, 241, 241)","hsl_parent_dependency":{"h":0,"s":0,"l":0.94}}},"gradients":[]},"original":{"colors":{"36c04":{"val":"rgb(255, 204, 102)","hsl":{"h":40,"s":1,"l":0.7}},"3a8fd":{"val":"rgb(241, 241, 241)","hsl_parent_dependency":{"h":0,"s":0,"l":0.94}}},"gradients":[]}}]}__CONFIG_colors_palette__

​Get Good at Excel on Autopilot

Sign up to our newsletter and receive ​Excel articles, tips and tricks delivered straight to your inbox. All you have to do is read them! ​Plus, to get you started, you'll receive a PDF with 200+ Excel shortcuts.

__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"2dd0d":{"name":"Main Accent","parent":-1}},"gradients":[]},"palettes":[{"name":"Default Palette","value":{"colors":{"2dd0d":{"val":"rgb(45, 164, 92)","hsl":{"h":143,"s":0.57,"l":0.41}}},"gradients":[]},"original":{"colors":{"2dd0d":{"val":"rgb(19, 114, 211)","hsl":{"h":210,"s":0.83,"l":0.45}}},"gradients":[]}}]}__CONFIG_colors_palette__
Join List
>