Skip to content

Combine tests with AND, OR and NOT

Logic and decisions8 min

Builds on Decide with IF.

HR at a company in Spain offers a training budget to staff with at least two years' service and a performance rating of 4 or more. Each person has to pass both tests, and IF on its own runs only one.

How it works

AND(test1, test2, …) returns TRUE only when every test is TRUE. OR(test1, test2, …) returns TRUE when at least one test is TRUE. NOT(test) turns TRUE into FALSE and FALSE into TRUE.

Picture a door. With AND it has several locks, and you need every key. With OR it has several handles, and any one of them opens it. Each function returns TRUE or FALSE, so it can stand in a cell on its own or go inside IF as the test: =IF(AND(test1,test2),"Yes","No").

Each test is a full comparison with its own cell, so AND(F2>=2,F2<=5) checks that F2 is from 2 to 5. AND and OR take up to 255 tests.

Example

A team lead can approve a purchase alone when it's under €500 and the supplier is on the approved list. The amount is in G2 and the supplier's status in H2.

=AND(G2<500,H2="Approved")
TRUE when the amount in G2 is under 500 and the status in H2 is Approved, and FALSE otherwise.

A €480 order from an approved supplier gives TRUE. A €480 order from a new supplier gives FALSE, and so does a €620 order from anyone.

Common mistakes

  • =AND(F2>=2,<=5) isn't accepted, because every test needs its own cell. Write =AND(F2>=2,F2<=5).
  • =2<=F2<=5 doesn't check a range. Excel compares 2 with F2 first, then compares that TRUE or FALSE with 5, and the result is always FALSE. Use AND.
  • =OR(H2="Paid","Part paid") doesn't test H2 twice, because "Part paid" on its own isn't a test. Repeat the cell: OR(H2="Paid",H2="Part paid").
  • AND(H2="Paid",H2="Part paid") is never TRUE, since one cell can't hold both. For "either", use OR.

In short

  • AND needs every test to be TRUE, OR needs at least one, and NOT gives the opposite.
  • Inside IF: =IF(AND(test1, test2), value if true, value if false).
  • Every test needs its own cell reference, such as AND(F2>=2,F2<=5).

Practice

4 exercises · free with an account

Start practicing
  1. Not started

    1. Who qualifies for the training budget

    Formula · easy

  2. Not started

    2. Weekend or weekday rate

    Formula · medium

  3. Not started

    3. Fridge readings out of range

    Formula · medium

  4. Not started

    4. Route the sales leads

    Formula · hard