For an IF formula with 2 conditions in Excel, put AND or OR inside the first argument of IF. =IF(AND(A2>=60,B2>=75),"Pass","Fail") returns "Pass" only when both tests are true, and =IF(OR(A2>=60,B2>=75),"Pass","Fail") returns "Pass" when at least one is.
The cell references and thresholds here are examples. Swap in your own.
How IF works with two conditions
The IF function has three parts: IF(logical_test, value_if_true, [value_if_false]). Only the first two are required. IF itself checks a single logical test, so to check two things you first combine them into one TRUE or FALSE answer. AND and OR do that job.
Both functions take a list of tests and return a single logical value. Per Microsoft's documentation, each accepts up to 255 conditions, so everything below also works for three, four or more tests.
IF with AND: both conditions must be true
Use AND when a result should appear only if every test passes. Suppose column A holds a score and column B holds attendance as a percentage, and a student passes only with a score of at least 60 and attendance of at least 75:
=IF(AND(A2>=60,B2>=75),"Pass","Fail")
Example results:
| A2 (score) | B2 (attendance) | Result |
|---|---|---|
| 70 | 80 | Pass |
| 70 | 60 | Fail |
| 50 | 90 | Fail |
| 50 | 60 | Fail |
Microsoft's own AND page uses the same pattern for a bonus: =IF(AND(B14>=$B$7,C14>=$B$5),B14*$B$8,0) pays a percentage of sales only when both the sales goal and the account goal are met, and returns 0 otherwise. Note that the value arguments do not have to be text. They can be a number, a calculation or a cell reference.
IF with OR: either condition is enough
Use OR when one passing test is enough. Here a discount applies to customers whose tier in column C is Gold or Platinum:
=IF(OR(C2="Gold",C2="Platinum"),10%,0)
It also works for numeric ranges. This formula flags a value that is outside the range 0 to 50 and shows it, otherwise it shows a message (adapted from Microsoft's OR page):
=IF(OR(A2<0,A2>50),A2,"The value is out of range")
Be careful with the wording. This example returns the number when it is outside the range, and the message when it is inside. If you wanted the opposite, swap the two result arguments or use AND with A2>=0,A2<=50.
Mixing AND and OR in one formula
You can nest one inside the other when the rule has three or more parts. A bonus is paid when the region is East and either sales reach 1,000 or the contract is renewed ("Yes" in column D):
=IF(AND(B2="East",OR(C2>=1000,D2="Yes")),"Bonus","No bonus")
Read it from the inside out: OR resolves to one TRUE or FALSE, and AND then combines that with the region test. Keep each function's brackets matched. If Excel reports a problem with the formula, count the opening and closing brackets first.
Different results for different conditions: nested IF
AND and OR give you two outcomes. When each condition should produce its own result, put a second IF in the "false" slot of the first:
=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","F")))
Excel tests left to right and stops at the first true test, so order matters. If you tested A2>=70 first, a score of 95 would return "C". Start with the strictest condition.
You can combine this with AND to cover two-sided rules:
=IF(AND(A2>=0,A2<50),"Low",IF(AND(A2>=50,A2<100),"Medium","Check value"))
The last result catches everything else, such as negative numbers and values of 100 or more.
The IFS alternative
IFS takes pairs of a test and a result, so there are no nested brackets to close: IFS(logical_test1, value_if_true1, [logical_test2, value_if_true2], ...). It supports up to 127 pairs. Microsoft lists it for Excel for Microsoft 365, Excel 2024, Excel 2021 and Excel 2019.
=IFS(A2>=90,"A",A2>=80,"B",A2>=70,"C",TRUE,"F")
The final TRUE,"F" pair is the default. Without it, a value that matches no test returns #N/A. You can also place AND or OR inside any IFS test, for example IFS(AND(A2>=60,B2>=75),"Pass",TRUE,"Fail"). If a workbook must open in a version without IFS, use nested IF instead.
Multiplication instead of AND
A comparison returns TRUE or FALSE, and Excel treats those as 1 and 0 when you multiply them. So (A2>=60)*(B2>=75) equals 1 only when both are true, and IF treats any non-zero number as TRUE:
=IF((A2>=60)*(B2>=75),"Pass","Fail")
It gives the same answers as the AND version. AND is easier to read for most people, but the multiplication form is common in array formulas, where AND would collapse a whole range into a single answer.
Common mistakes
- Writing the two conditions as separate IF arguments.
=IF(A2>5,B2>5,"Yes")does not test two conditions. The second argument is the result when the first test is true. Wrap the tests in AND or OR. - Chained comparisons.
=IF(60<=A2<=100,...)does not work as it would in maths. WriteAND(A2>=60,A2<=100). - Numbers stored as text. A cell showing 70 that is left-aligned may be text, so numeric comparisons against it can give surprising answers. Convert it to a number first.
- A result of 0 where you expected text. Microsoft notes that a missing
value_if_trueorvalue_if_falseshows as 0. Always fill in both results. - #NAME? error. Usually a misspelled function name, or text in a test that is missing its quotation marks.
- #VALUE! from AND or OR. This happens when a range argument contains no logical values at all, because text and empty cells in a range are ignored. Pass comparisons, not raw ranges.
For the related cases of testing for empty cells and partial text matches, see Excel IF not blank formulas and Excel IF cell contains text.
Frequently asked questions
- How many conditions can AND and OR take?
- Both functions accept up to 255 conditions, according to Microsoft's documentation. The first is required and the rest are optional, so the same pattern works for two conditions or twenty.
- Why does my IF with AND return FALSE when one cell is empty?
- A direct comparison such as B2>=75 treats an empty cell as 0, so the comparison is FALSE and AND fails. Add a test such as B2<>"" as another condition if empty cells should be handled differently.
- Should I use nested IF or IFS?
- Use IFS if your Excel version has it (Excel 2019, Excel 2021, Excel 2024 and Microsoft 365). It reads left to right without closing brackets piling up. Use nested IF if the file must open in older versions such as Excel 2016, which do not have IFS.
- Can I put text conditions in AND or OR?
- Yes. Compare the cell to a quoted string, for example A2="East". The comparison itself returns TRUE or FALSE, which is what AND and OR need.