Menu

Excel AND, OR and NOT Functions with IF: Examples

=AND(B2>=10,B2<=20) returns TRUE only when every condition is true, and =OR(B2="North",B2="South") returns TRUE when at least one is. Learn AND, OR, NOT and XOR on their own and inside IF, how to test whether a number is between two values, and how to write AND and OR in array formulas.

Every sheet on this page is live: change a number or a formula and it recalculates.

=AND(B2>=50,C2>=50) returns TRUE only when both conditions are true. =OR(B2>=50,C2>=50) returns TRUE when at least one of them is. Inside IF they turn two conditions into one test: =IF(AND(B2>=50,C2>=50),"Pass","Fail").

Pass both parts, or either
D2
ABCDE
1StudentExamProjectBoth 50+Either 50+
2Ana7264PassPass
3Ben4580FailPass
4Chloe5851PassPass
5Dan3842FailFail
6Eve9147FailPass
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Ben and Eve pass one part and fail the other, so they fail column D (AND) and pass column E (OR). Dan fails both and fails both columns. Change Ben's exam in B3 to 55 and he passes in D too.

AND function

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

AND takes up to 255 conditions and returns TRUE only if every one of them is TRUE. One FALSE is enough to make the result FALSE. On its own, AND shows TRUE or FALSE in the cell; inside IF it decides which result IF returns.

Check if a number is between two values

Excel has no BETWEEN function. Use AND with a lower and an upper bound:

Is the temperature in range?
C2
ABCD
1SampleTempBetween 10 and 20Status
2S114TRUEOK
3S222FALSECheck
4S310TRUEOK
5S47FALSECheck
6S520TRUEOK
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

S3 and S5 sit exactly on the bounds and count as in range, because the tests use >= and <=. To exclude the bounds, use > and <. Keeping the bounds in cells, =AND(B2>=$F$1,B2<=$F$2), lets you change the range without editing the formula. A test like 10<=B2<=20 does not work in Excel: it compares 10<=B2 (TRUE or FALSE) with 20, and Excel ranks TRUE and FALSE above every number, so the result is always FALSE.

OR function

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

OR returns TRUE if at least one condition is TRUE, and FALSE only when all of them are FALSE. It is the usual way to accept several text values:

Zone by region
C2
ABC
1OrderRegionZone
21001NorthZone 1
31002EastZone 2
41003SouthZone 1
51004WestZone 2
61005southZone 1
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Text comparisons ignore case, so south in lower case also lands in Zone 1. For a long list of accepted values, =OR(B2={"North","South","Central"}) compares B2 with each item of the array constant in one go.

NOT and XOR

NOT reverses a logical value: =NOT(TRUE) is FALSE. It reads well when the condition you have is the opposite of the one you want: =IF(NOT(C2="Done"),"Follow up","") is the same as =IF(C2<>"Done","Follow up","").

XOR, available since Excel 2013, is the exclusive or: with two conditions it is TRUE when exactly one of them is TRUE, and FALSE when both are TRUE or both are FALSE. With more conditions, it is TRUE when an odd number of them are TRUE.

NOT and XOR
D2
ABCDE
1TaskOwnerStatusOpenOne check only
2ReportAnaDoneFALSEFALSE
3BudgetBenOpenTRUEFALSE
4SlidesAnaOpenTRUETRUE
5SurveyBenDoneFALSETRUE
6PlanAnaDoneFALSEFALSE
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Column E is TRUE for Slides (Ana but not Done) and Survey (Done but not Ana), and FALSE where both or neither hold.

AND and OR together

Conditions can be nested: AND inside OR or OR inside AND. A rep gets a bonus when they are in the North region and either sold more than 1,000 or signed a new client:

Bonus rule
E2
ABCDE
1RepRegionSalesNew clientBonus
2AnaNorth1200NoBonus
3BenNorth700YesBonus
4ChloeSouth1500Yes
5DanNorth900No
6EveNorth1100YesBonus
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Ana (sales), Ben (new client) and Eve (both) get the bonus. Chloe meets the OR part but is in the South, and Dan is in the North but meets neither OR condition.

Practice: free shipping

Free shipping
D2
ABCD
1OrderTotalMemberShipping
2100135Yes
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Your turn: In D2, show "Free" when the order total in B2 is at least 50 or the customer is a member (C2 is "Yes"), otherwise show "Paid".

AND and OR in array formulas: use * and +

AND and OR collapse everything they are given into one TRUE or FALSE. That is what you want in a single row, but not when a formula works on a whole column at once: =AND(B2:B6="North",C2:C6>100) returns one value for the five rows together. In array formulas (FILTER, SUMPRODUCT, SUM over a condition) write the conditions in brackets and multiply them for AND, add them for OR. TRUE counts as 1 and FALSE as 0, so a product is 1 only when both are true, and a sum is at least 1 when either is.

Count with * and +
F2
ABCDEF
1RepRegionSalesCount
2AnaNorth1200North and over 1,0002
3BenSouth700North or over 1,0004
4ChloeNorth900
5DanSouth1500
6EveNorth1100
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

F2 counts 2 rows (Ana and Eve), F3 counts 4 (everyone except Ben). In F3 the >0 matters: a row that meets both conditions adds up to 2, and the comparison turns any sum above 0 into one TRUE. The same pattern filters rows, =FILTER(A2:C6,(B2:B6="North")*(C2:C6>1000)); for plain counting with AND logic, COUNTIFS does it without arrays: =COUNTIFS(B2:B6,"North",C2:C6,">1000"), see the COUNTIFS page.

Frequently Asked Questions

How do I use IF with AND in Excel?

Put AND in IF's test: =IF(AND(B2>=50,C2>=50),"Pass","Fail"). The result is Pass only when both B2 and C2 are 50 or more.

How do I check if a number is between two values in Excel?

Use AND with two comparisons: =AND(B2>=10,B2<=20) returns TRUE for any value from 10 to 20, both included. Inside IF: =IF(AND(B2>=10,B2<=20),"In range","Out of range").

What is the difference between AND and OR in Excel?

AND returns TRUE only when every condition is TRUE. OR returns TRUE when at least one condition is TRUE. =AND(TRUE,FALSE) is FALSE and =OR(TRUE,FALSE) is TRUE.

Why does AND not work in my FILTER or SUMPRODUCT formula?

AND and OR reduce a whole range to one TRUE or FALSE instead of one per row. In array formulas multiply the conditions for AND, (B2:B6="North")*(C2:C6>100), and add them for OR.

Can I use AND and OR in the same formula?

Yes, nest one inside the other: =IF(AND(B2="North",OR(C2>1000,D2="Yes")),"Bonus","") requires North plus either sales over 1000 or a Yes in D2.

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED