Quick, clean, and to the point

If this AND that OR that

Excel formula: If this AND that OR that
Generic formula 

To test for various combinations of this AND that, or this OR that, you can use the IF function with the AND and OR functions. In the example shown, the formula in D6 is:


When an item is "red", and either "small" or "medium", the formula returns "x". All other combinations return an empty string ("").


In the example shown, we simply want to "mark" or "flag" rows where the color is "red" AND size is either "small" or "medium". To return TRUE when items are red and small, we can use a logical statement constructed with the AND function:


To extend the statement to return TRUE when items are red and either small or medium, we can nest the OR function inside the AND function like this:


This snippet will return TRUE only if the value in B6 is "red" AND the value in C6 is either "small" or "medium". It is placed inside the IF function as the logical test. When the logical test returns TRUE, the IF function returns "x". When the logical test returns FALSE, the IF function returns an empty string ("").

Change the values returned by IF to suit your needs.

Dave Bruns

Excel Formula Training

Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.

Download 100+ Important Excel Functions

Get over 100 Excel Functions you should know in one handy PDF.