Excel Supreme

Excel track · Exercise 24 of 86 Paid

AND, OR and NOT: combining tests

Combine several tests into one answer, and choose AND or OR to match the question.

Advanced

Stock list with a total row and a smallest item

Read-only data · screen 1 of 2 · answer in B9

In B9, answer TRUE only when the total is over 100 and every item has at least 15 units.

AB
1ItemUnits
2Bolt18
3Nut22
4Washer25
5Screw30
6Clip24
7Pin31
8Total150
9Both tests

Download this grid (.xlsx) Two tabs: the grid you see, and the answer.

B9

What it does

AND, OR and NOT take logical tests and return a single TRUE or FALSE. AND needs every argument to hold and OR needs one, while NOT flips the value it is given. Each argument is normally a comparison, though a bare number counts as TRUE unless it is zero.

On this sheet the total is 150 and the smallest item is 18. Both tests in =AND(B8>100,MIN(B2:B7)>=15) hold, so the cell answers TRUE. The second screen asks whether any item is under 20 or the total is over 200, and Bolt's 18 settles it on the first test alone.

Most mistakes here come from choosing between AND and OR. On data like this either function answers TRUE, so a wrong choice stays hidden until a month when the two tests disagree.

Syntax

=AND(test1, test2, ...) needs every test; =OR(...) needs one; =NOT(test) flips it

Worked example

On Stock list with a total row and a smallest item, =AND(B8>100,MIN(B2:B7)>=15) returns true.

=AND(B8>100,MIN(B2:B7)>=15)

Common errors

Error codes for AND and OR over comparison arguments, and what a bare number argument means
ErrorWhat it means and how to fix it
#VALUE!An argument is text where a logical test belongs, as when a word reaches AND without quotes.
#NAME?A function name is mistyped, so no test runs at all.
One test onlyA formula holding a single comparison looks complete but skips the second condition, so a short item still passes.

At work

Marking a month for restock only when the stock total is low and one line has run short.