The book: files and exercises · Lesson 8 of 24

Lesson 8 exercises: the IF function, with AND and OR

Four exercises on the IF function and on conditions with AND and OR, with the office supplies stock from lesson08.xlsx. Type the formula in the fx bar: the page copies it to every row and also tests it with values right on the limit.

Lesson 8. IF, AND, OR: decisions inside a cell

Use the file lesson08.xlsx.

Files: lesson08.xlsx · solutions: lesson08-solutions.xlsx.

In the exercises with a sheet, type the formula in the fx bar and click Check: the sheet works it out the way Excel does, with commas between the arguments (semicolons work too), and also tries it with other data, to see whether it still works when the data changes. In the other exercises, you work in Excel with the lesson's file and type the result here.

At the end of the page you'll find the lesson's Bonus challenge: one more exercise, whose answer isn't in the book. You check it only here.

Exercise 1

Exercises sheet: in D4, type a formula that shows "Order" when the stock is less than the minimum, and "OK" otherwise. Copy it down to D10. How many items do you need to order, and which ones?
In cell D4 (the check copies the formula down to D10, like the fill handle)
fx
How many items do you need to order?
Which ones? (separate them with commas)
Show the answer

=IF(B4<C4,"Order","OK"): 4 items, Blue pens, Notebooks, Highlighters and Glue sticks (the erasers, with 25 for a minimum of 25, are not below the minimum).

Exercise 2

Same sheet: in E4, type a formula that shows "Warning" when the stock is 0 or above 100, and leaves the cell empty otherwise (hint: "", two quotes with nothing between them, is an empty text). Copy it down to E10. Which items show "Warning"?
In cell E4 (the check copies the formula down to E10, like the fill handle)
fx
Which items show Warning?
Show the answer

=IF(OR(B4=0,B4>100),"Warning",""): Pencils (120) and Highlighters (0).

Exercise 3

Orders sheet, with the formulas from section 8.4: change the limit in I3 from 500 to 300. How many orders get a discount now, and what is the total of the discounts in D12? (Then put 500 back.)
How many orders get a discount now?
What is the total of the discounts in D12?
Show the answer

With the limit at $300.00, 6 orders get a discount (all except Zeta LLC and Theta Inc.), and the total of the discounts rises to $194.50.

Exercise 4

Without Excel: B2 holds 20 and C2 holds the text No. What does =IF(AND(B2>=18,C2="Yes"),"Accepted","Declined") return?
What does the formula return?
Show the answer

"Declined": the first condition is true, the second is not, and AND needs both to be true.

Bonus challenge

The answer isn't in the book: you check it only here.

Exercises sheet: in F4, type one formula, to copy down to F10, that shows "Urgent" when the stock is 0, "Order" when it is below the minimum, and "OK" in every other case. The order of the tests matters! How many items show "Order"?
In cell F4 (the check copies the formula down to F10, like the fill handle)
fx
How many items show Order?
Show the answer

=IF(B4=0,"Urgent",IF(B4<C4,"Order","OK")), copied down to F10. The test for 0 has to come first: a stock of 0 is always below the minimum, so if you test B4<C4 first, the highlighters end up as "Order" and "Urgent" never shows. Result: the highlighters show Urgent, 3 items show "Order" (blue pens, notebooks and glue sticks) and the others show "OK".