### Excel Cram Kit (Exam 2)

AND vs. OR
HLOOKUP
Excel Tables
PivotTables
COUNTIF, SUMIF, AVERAGEIF
SUMPRODUCT
3D Cell References

# AND

Imagine you're back in middle school, and your team just won your hometown Little League baseball series. High off of the adrenaline from riding the bench while your star teammate hit the game-winning home run, your parents decide to treat you to some ice cream!

But... this isn't just any normal trip to the ice cream shop. This time, you get to pick as many toppings as you want. Time to go absolutely crazy and seize this opportunity.

As you stand 10ft away from the cashier surveying the toppings options, you decide on crushed graham crackers and chocolate fudge drizzle. With chest puffed out with pride, you strut to the window of the shop and state the following to the cashier:

"I'd like vanilla ice cream with crushed graham crackers and chocolate fudge drizzle."

Man, it feels good to be a champion.

Story aside, what we did here was define two conditions about our ice cream that must be true to keep us happy. You must have both crushed graham crackers AND chocolate fudge drizzle to be happy with your ice cream. If either of those are missing, then you won't accept your ice cream.

In summary...

AND defines two or more conditions that must both be true in order for the function to return true. If any of the conditions are false, then the entire function returns false.

## How to code an AND

Let's the above scenario to an Excel worksheet to exemplify how we could accomplish it with actual code.

Below is the template for AND functions:

=AND(logical1, [logical2], ...)

For our first order, we stated that we want both crushed graham crackers and chocolate fudge drizzle. These toppings are in cells A4 and A8. Considering that the result of our toppings are in cells D2 and E2, we'd structure our AND function like so:

=AND(D2=A4, E2=A8)

What this means is that our first topping (D2) must equal Crushed Graham Crackers (A4)...

=AND(D2=A4, E2=A8)

...and our second topping (E2) must equal Chocolate Fudge Drizzle.

=AND(D2=A4, E2=A8)

When we code this, we get the following result:

In order for it to return true, we must input the toppings we got.

Notice how if we were to switch Crushed Graham Crackers with Chocolate Sprinkles, we'd get false in return.

This is because our first logical statement is now false, so the entire AND function returns false. Remember, with AND functions all the conditions within it must be true for it to return true!