What OR does
OR checks two or more conditions and returns TRUE when at least one of them is true, and FALSE only when all of them are false. =OR(B2="Sat",B2="Sun") is TRUE for a shift on a Saturday or a Sunday, because either day makes it a weekend shift.
Like AND, it can stand alone and fill a cell with TRUE or FALSE, or sit inside IF as the test. It suits flags and exceptions, such as reviewing an invoice when it’s large or when the supplier is new.
Syntax
logical1Required- The first condition, such as
B2="Sat". Anything that works out to TRUE or FALSE will do. logical2Optional, can repeat- More conditions, separated by commas, up to 255 in all. OR is TRUE as soon as any one of them is TRUE.
Example: flag the weekend shifts
The day of each shift is in column B. The formula in C2 is filled down to C5.
Example: OR as the test inside IF
Invoices over €1,000, or from a new supplier, need a second look.
An invoice that’s both large and from a new supplier is reviewed too, since OR needs only one condition to hold.
The free lesson Combine tests with AND, OR and NOT has you set a weekend pay rate with OR inside IF.
Common mistakes
=OR(B2="Sat","Sun")doesn’t compare B2 with “Sun”. The second argument is just the text “Sun”, which Excel can’t read as TRUE or FALSE, so the cell shows#VALUE!. Write each comparison in full:B2="Sun".=IF(B2>1000 OR C2="New",…)isn’t valid. The conditions go inside OR, separated by commas.- If a claim needs a receipt and has to be under the limit, OR lets through claims that meet just one rule. That rule needs AND.
- Ten
B2="…"conditions are hard to read and easy to break. Keep the values in a short list on the sheet and count matches with COUNTIF:COUNTIF(list,B2)>0.
Frequently asked questions
Can I use AND and OR together?
Yes, one inside the other. =AND(B2>1000,OR(C2="New",C2="Overseas")) is TRUE for large invoices from a supplier that’s either new or overseas.
How do I use OR with text?
Compare the cell with each text value in quotation marks: =OR(B2="Sat",B2="Sun"). Capitals don’t matter, so “sat” and “SAT” match too.
Can I use OR in SUMIFS or COUNTIFS?
Not inside them, because SUMIFS and COUNTIFS only include rows that meet every condition. For an either-or total, add two of them together: =SUMIFS(C2:C9,B2:B9,"North")+SUMIFS(C2:C9,B2:B9,"South") adds the sales from both regions.
Can I use OR in conditional formatting?
Yes. Select the rows, choose Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format, and enter a rule such as =OR($B2="Sat",$B2="Sun") to color the weekend shifts.
Why is my OR formula not working?
Check that each condition is a full comparison: in =OR(B2="Sat","Sun") the second part is only the text Sun, so the cell shows #VALUE!. If OR says TRUE on every row, the conditions may cover every possible value, as B2>100 and B2<500 together do; to test for a value between two numbers, use AND.