Using the IF statement (texts)
Overview
The "IF" function (also called: "If Statement") is composed of three parts separated by commas: A condition, what to display if the condition is met, and what to display if the condition isn’t met.
Building the IF function step by step:
- Select the cell in which you want the IF function to be.
- Type the following code: =if(
- Type the condition.
- Type a comma.
- Type what you want to display if the condition is met (if it is text, then write the text within quotation marks).
- Type a comma.
- Type what you want to display if the condition isn’t met.
- Close the bracket and hit the [Enter] key.
Examples
=if(B5>50000,”too expensive”,”let’s buy it”)
In words: If the value of cell B5 is greater than 50,000 then show the words “too expensive”, otherwise show the words “let’s buy it”.
=if(A6=”Monday”,”Back to work”,”Stay at vacation”)
In words: If the value of cell A6 is the word “Monday” then show the words “Back to work”, else show the words “Stay at vacation”.
=if(B2=”Jermey”,”A great kid”,””)
In words: If the value of cell B2 is the word “Jermey” then show the words “A great kid”, otherwise leave the cell empty.
Advanced IF examples (using it with the OR and AND functions):
=if(or(A5=”Saturday”,A5=”Sunday”),”This is weekend”,”This is a working day”)
In words: if the value of cell A5 is “Saturday” or the value of cell A5 is “Sunday” then show the words “This is weekend”, else show the words “This is a working day”.
=if(and(A3=”Jack”,B3=”Bauer”),”Found the guy”,”That isn’t him”)
In words: if the value of cell A3 is “Jack” and the value of cell B3 is “Bauer” then write “Found the guy”, else write “That isn’t him”.