180 likes | 307 Views
Excel: Logical Tests. Some text and examples used with permission from: http://www.jegsworks.com Note: We are not endorsing or promoting religious doctrine, but simply taking advantage of this website for educational purposes . Computer Information Technology Section 6-17. Objectives.
E N D
Excel: Logical Tests Some text and examples used with permission from: http://www.jegsworks.com Note: We are not endorsing or promoting religious doctrine, but simply taking advantage of this website for educational purposes. Computer Information Technology Section 6-17
Objectives • The student will • Understand conditional expressions and how they are used. • Know the format for the “IF” function in Excel. • Understand the logical operators. • Understand how to set conditional formatting in a cell
Excel: Logical Tests • Some functions do not calculate values but instead do logical tests using logical comparisons like =, < , and > or the combinations <=, >=, <>. • Such a test allows you to do one thing when the comparison is TRUE and something different when it is FALSE.
Excel: The IF function • The IF function is the logical test that is used the most. It has three arguments inside parentheses which are separated by commas: • the comparison statement • the cell value to use when the comparison is true • the cell value to use when the comparison is false. • This is also know as IF – THEN – ELSE • If it is true then do this, else do that
Excel: The IF function • The general form of an IF function is: =IF(logical comparison, value if TRUE, value if FALSE) • A value can be a number, text within double quotes, a cell reference, a formula, or another logical test.
Excel: Nesting Statements • You can nest up to 7 If statements to create complex tests. For example, to calculate your letter grade based on your percent score I use the following statement: =IF(F4>0.895,"A",IF(F4>0.795,"B",IF(F4>0.695,"C",IF(F4>0.595,"D","F"))))
Conditional Formatting • Conditional formatting: uses a logical test to apply one format for a cell when the test is true and a different format when it is false. • For example, you could format positive amounts with a green cell fill and negative amounts with a red fill.
Excel: Conditional Formatting • If I want to automatically put a red fill in all cells for students who are failing my first period class. • First step is to select the cells containing the grades
Excel: Conditional Formatting • In the Style group on the Home tab click Condition Formatting • This brings up the conditional formatting menu:
Excel: Conditional Formatting • In this case we want to highlight the cells with a certain value. • Choose Highlight Cells Rules • Choose Equal to
Excel: Conditional Formatting • Once a value (F) is entered for Format cells that are EQUAL TO: the formatting is applied. • There are a number of build in formats, or create a custom format. • I want a bright red background
Excel: Conditional Formatting • Formatting Dialog box pops up • Click on Fill • Choose Red • Click OK
Excel: Conditional Formatting • Click OK • All Fs will now be red
Excel: Conditional Formatting • You can add other formatting conditions. • I can shade all As green putting in second condition using the same steps. • The file now looks like this
Summary • The IF function is used to set values or formulas based on conditions • The format for the IF function is: • Conditional formatting is used to set the formatting based on a certain condition. • =IF(logical comparison, value if TRUE, value if FALSE)
Rest of today • From the Hancock website download: Call attention to the good or the bad.xls Homework 6-17 • Do Exercises 1 and 2 in Homework 6-17 – Save the file as Homework 6-17 • Do not print – Show me the file on your screen to get credit. • Mavis Beacon for 15 minutes