Thursday, October 21, 2010

EXCEL TIP: The IF Statement made simple

One of the functions I use most often in Excel is the IF statement. This function is very powerful and to many can seem very complicated, whereas to others it is deceptively simple and its power can be underestimated.

The basic IF statement


The basic format of an IF statement is as follows:

=IF(if this is true,return this,otherwise return this)


Example:

=IF(A2>3,"Greater than three","Not greater than three")

returns the text Greater than three if the number in cell A2 is greater than 3 and Not greater than three, if it is not.

The first argument can be any expression that can be true or false, usually using =,>,<,<=,>= or <>.

Other Examples:

=IF(A3="X","Yes","No")
=IF(SUM(A2:A10)>B2,"Over Budget","Within Budget")
=IF(A2<0,0,A2)

Combining conditions


All of the above examples include only one condition, but it is possible to combine numerous conditions using the AND and OR functions.

Theses functions are formatted as follows:

=AND(Condition 1, Condition 2, Condition 3.....Condition n)
=OR(Condition 1, Condition 2, Condition 3.....Condition n)

The AND function returns TRUE if ALL of the individual conditions are true.

The OR function returns TRUE if ANY of the individual conditions are true.

They can be used in IF statements as follows:

=IF(AND(A2<=200,A2>=100),"In Range","Out if Range")
=IF(OR(A2="X",B2="X",C2="X"),"Contains X","Doesn't Contain X")

More complex decisions (Nested IF Statements)


If the decision required is more complicated, you can have IF statements within IF statements - this is called Nesting.

Example:

=IF(A2=0,"NIL",IF(A2>0,"POSITIVE","NEGATIVE"))

If A2 is 0, this will return the word NIL, however if A is not 0 the third argument is another IF statement that will return the word POSITIVE if A2 is greater than zero, otherwise it will return NEGATIVE.

And that is the IF statement. Don't forget you can still take the easy route and get your spreadsheet built for you at Spreadsheets by Email.


If you enjoyed this post, go to the top left corner of the blog, where you can subscribe for regular updates and your free report. If you wish to help me to provide future posts like this, please consider donating using the button in the right hand column.

7 comments:

Anonymous said...

now in my rss reader))) financial help

Anonymous said...

Thanks for sharing us informative ideas.

Julie said...

Finally, an understandable explanation of the IF statement. Thank you very much!

Glen Feechan said...

Julie, pleased you found it useful.

Jazzie Casas said...

I'm a single dad of 2 age 2 and 5. I find your site so interesting and helpful. I hope I have much time each day to drop by and check your site for recent post. By the way I really appreciate the effort for sharing this.. Thank you..

Excel Statement said...

The IF function is my go-to as well. It is the first function I turn to to approach any formula. Probably not the best process but that goes to show how big of an impact it has had.

Good work covering the basics.

-Grahm
Excel Statements

Mia B said...

One of the clearest (and shortest) overviews on this topic...thank you.

Mia B.
excel statement

About this blog

Not Just Numbers is sponsored by:
needaspreadsheet.com
Regus House
Doxford International Business Park
Sunderland
SR3 3XW
T: +44 (0)845 6439693
F: +44 (0)191 2477103
W: needaspreadsheet.com
E: enquiries@needaspreadsheet.com