Nested Conditional Statements

advertisement
Conditional Statements
The general form of a conditional statement is: =IF(Condition,True,False)
The three inputs—Condition, True, and False—identify the parameters and provide
instructions on what actions to perform if the condition is true, and what actions to
perform if the condition is false. Note that there is no space following the commas within
the conditional statement as well as none preceding or following the word IF.
Some examples of conditional statements follow:
=IF(B4>100,25,B2+5)
If the value displayed in cell B4 is greater than 100, then enter the value 25 in this
cell; if the value in cell B4 is less than 100, then enter the value of B2 plus 5 in this cell.
=IF(A16=“Exempt”,100, “”)
If the text Exempt appears in cell A16, then enter the value 100 in this cell, or else
leave it blank. Note: text must be enclosed in double quotation marks or else you will
receive an error message such as #VALUE!. Two double quotation marks with no
intervening space is a “blank” and is treated as text by Excel.
Note: If you copy a formula from Word to Excel, you will need to change the
quotation marks to straight rather than curled. If you do not, then you will encounter an
error message.
=IF(C7<12,C7+1,1)
If the value displayed in cell C7 is less than 12, then have this cell display the
value of C7 plus 1, or, if the value equals 12 (or higher), then display the value 1.
=IF(B6*B7>0,A12/$B$7,””)
If the product of B6 times B7 is greater than zero, then enter the value of cell A12
divided by the value of B7; or else, leave this cell blank. (This will avoid the problem of a
#DIV/0! error message if B7 equals zero.)
Use Excel to open the spreadsheet named Condition1.xls, then follow these instructions:
Enter the first formula (above) in cell B3. What value is displayed in B3? ________
Change the value in b4 to 115. What value is displayed in cell B3? ________
Enter the second formula (above) in cell B16. What value appears in cell B16? ________
Delete the word Exempt in cell A16. What appears in cell B16? ________
Enter the third formula (above) in cell C8. Copy this cell down through cell C25. What
happens? ________________________________________________________________
Enter the fourth formula (above) in cell B12. What is displayed in cell b12? _______
Change the value in cell B7 to zero. What is displayed in cell B11?________ and in cell
B12? ________
Nested Conditional Statements
Conditional statements can be nested—that is a conditional statement can contain another
conditional statement which may itself have yet a third conditional statement. This
nesting of conditional statements can be valuable in certain applications, but there is a
limit of about seven for nested statements.
=IF(Condition,True,IF(Condition,True,False))
In this case, the False part of the first conditional statement has been replaced by a
second conditional statement. This permits the application of multiple conditions in a
sequentially-evaluated formula.
Put the following conditional statement into cell D16:
=IF(B16=100,”High Pass”,IF(B2*B6>80,”Pass”,”Failed”))
Change cells A16, B2 and B6 to see what happens. Are you able to produce all three
possible responses (High Pass, Pass, Failed)? ________
Go to the menu bar in Excel and click on Tools, then select Options, then click in the box
marked Formulas (in the Window Options section). This will display the formulas on
your spread sheet. Add your name as a header, then print a copy of the spreadsheet
which displays the formulas which you entered. Turn this in along with your responses
on the attached sheet.
Start on Spreadsheet Exercise #2 (Growth).
Download