Introduction To The IF Statement


The IF function is sometimes not used as much as it could be especially by new Excel users.,  get to make friends with it and it is certain to make your life easier.

The basics of the IF function is to answer the questions ….Is this true or false then, proceed to take some action.

The parts of an IF statement are as follows

Logical test– what are we asking

Value if true– what we want to be displayed of the answer to our question is true

Value if false– what we want to be displayed if the answer to our question is false.

It’s always easier with an example so let’s use one.

In a formula the arguments are seperated by commas, so for this exmaple let’s put our formula into cell C1

It looks like this

=IF(A2>B2,”BIGGER”, “SMALLER”)

So in English this formula reads as follows-

IF THE VALUE IN A2 IS GREATER THAN THE VALUE IN B2, PUT ‘BIGGER ‘IN C2, IF IT IS NOT GREATER THEN PUT ‘SMALLER’ IN C2.

Note that when you want text to be displayed in a cell, then you need to put it in quotes so Excel recognises that it is text, if you only wanted your true and false arguments to be numeric there is no need for the quotation marks, so the same formula would read like the below if you replaced BIGGER and SMALLER with 1 and 2.

=IF(A2>B2,1,2)

The IF statement is very versatile and can out pretty much anything in the second parts of the formula.

If you wanted to indicate As seen above you can request a to put text or a number as part of your formula, but you can also ask for the cell to be left blank just by using two quotes as that part of the formula or argument.  Our same formula would therefore look like this if we wanted the cell to be left blank if the argument of A2 being bigger than B2

=IF(A2>B2,”YES,””)

Let’s turn up the volume slightly on this IF statement stuff.  We can also insert cell references in the second two parts of the formula or parts of the argument. So if we want the value ‘if false’ to be something in another cell we can just put that cell reference or name in the the third part of the formula or argument, so let’s look at our example and look for the contents of cell reference D2 to returned in the third part of the formula

=IF(A2>B2,”YES,$D$2).

Note that the dollar signs surround the cell reference. This is because we ALWAYS want the formula to refer to that cell.  The dollar signs make the cell reference ‘absolute’.

Check out my link below HERE more information on absolute cell references.

Barbara

Barbara is an experienced data analyst with over 20 years of experience. Author of the How To Excel At Excel Top 50 Excel tips Ebook, YouTuber and Excel Blogger.

Recent Posts