The IF function allows you to make a logical comparison between a value and what you expect by testing for a condition and returning a result if that condition is True or False.
-
=IF(Something is True, then do something, otherwise do something else)
But what if you need to test multiple conditions, where let’s say all conditions need to be True or False (AND), or only one condition needs to be True or False (OR), or if you want to check if a condition does NOT meet your criteria? All 3 functions can be used on their own, but it’s much more common to see them paired with IF functions.
Use the IF function along with AND, OR and NOT to perform multiple evaluations if conditions are True or False.
Syntax
-
IF(AND()) — IF(AND(logical1, [logical2], …), value_if_true, [value_if_false]))
-
IF(OR()) — IF(OR(logical1, [logical2], …), value_if_true, [value_if_false]))
-
IF(NOT()) — IF(NOT(logical1), value_if_true, [value_if_false]))
Argument name |
Description |
|
logical_test (required) |
The condition you want to test. |
|
value_if_true (required) |
The value that you want returned if the result of logical_test is TRUE. |
|
value_if_false (optional) |
The value that you want returned if the result of logical_test is FALSE. |
|
Here are overviews of how to structure AND, OR and NOT functions individually. When you combine each one of them with an IF statement, they read like this:
-
AND – =IF(AND(Something is True, Something else is True), Value if True, Value if False)
-
OR – =IF(OR(Something is True, Something else is True), Value if True, Value if False)
-
NOT – =IF(NOT(Something is True), Value if True, Value if False)
Examples
Following are examples of some common nested IF(AND()), IF(OR()) and IF(NOT()) statements. The AND and OR functions can support up to 255 individual conditions, but it’s not good practice to use more than a few because complex, nested formulas can get very difficult to build, test and maintain. The NOT function only takes one condition.
Here are the formulas spelled out according to their logic:
Formula |
Description |
---|---|
=IF(AND(A2>0,B2<100),TRUE, FALSE) |
IF A2 (25) is greater than 0, AND B2 (75) is less than 100, then return TRUE, otherwise return FALSE. In this case both conditions are true, so TRUE is returned. |
=IF(AND(A3=»Red»,B3=»Green»),TRUE,FALSE) |
If A3 (“Blue”) = “Red”, AND B3 (“Green”) equals “Green” then return TRUE, otherwise return FALSE. In this case only the first condition is true, so FALSE is returned. |
=IF(OR(A4>0,B4<50),TRUE, FALSE) |
IF A4 (25) is greater than 0, OR B4 (75) is less than 50, then return TRUE, otherwise return FALSE. In this case, only the first condition is TRUE, but since OR only requires one argument to be true the formula returns TRUE. |
=IF(OR(A5=»Red»,B5=»Green»),TRUE,FALSE) |
IF A5 (“Blue”) equals “Red”, OR B5 (“Green”) equals “Green” then return TRUE, otherwise return FALSE. In this case, the second argument is True, so the formula returns TRUE. |
=IF(NOT(A6>50),TRUE,FALSE) |
IF A6 (25) is NOT greater than 50, then return TRUE, otherwise return FALSE. In this case 25 is not greater than 50, so the formula returns TRUE. |
=IF(NOT(A7=»Red»),TRUE,FALSE) |
IF A7 (“Blue”) is NOT equal to “Red”, then return TRUE, otherwise return FALSE. |
Note that all of the examples have a closing parenthesis after their respective conditions are entered. The remaining True/False arguments are then left as part of the outer IF statement. You can also substitute Text or Numeric values for the TRUE/FALSE values to be returned in the examples.
Here are some examples of using AND, OR and NOT to evaluate dates.
Here are the formulas spelled out according to their logic:
Formula |
Description |
---|---|
=IF(A2>B2,TRUE,FALSE) |
IF A2 is greater than B2, return TRUE, otherwise return FALSE. 03/12/14 is greater than 01/01/14, so the formula returns TRUE. |
=IF(AND(A3>B2,A3<C2),TRUE,FALSE) |
IF A3 is greater than B2 AND A3 is less than C2, return TRUE, otherwise return FALSE. In this case both arguments are true, so the formula returns TRUE. |
=IF(OR(A4>B2,A4<B2+60),TRUE,FALSE) |
IF A4 is greater than B2 OR A4 is less than B2 + 60, return TRUE, otherwise return FALSE. In this case the first argument is true, but the second is false. Since OR only needs one of the arguments to be true, the formula returns TRUE. If you use the Evaluate Formula Wizard from the Formula tab you’ll see how Excel evaluates the formula. |
=IF(NOT(A5>B2),TRUE,FALSE) |
IF A5 is not greater than B2, then return TRUE, otherwise return FALSE. In this case, A5 is greater than B2, so the formula returns FALSE. |
Using AND, OR and NOT with Conditional Formatting
You can also use AND, OR and NOT to set Conditional Formatting criteria with the formula option. When you do this you can omit the IF function and use AND, OR and NOT on their own.
From the Home tab, click Conditional Formatting > New Rule. Next, select the “Use a formula to determine which cells to format” option, enter your formula and apply the format of your choice.
Using the earlier Dates example, here is what the formulas would be.
Formula |
Description |
---|---|
=A2>B2 |
If A2 is greater than B2, format the cell, otherwise do nothing. |
=AND(A3>B2,A3<C2) |
If A3 is greater than B2 AND A3 is less than C2, format the cell, otherwise do nothing. |
=OR(A4>B2,A4<B2+60) |
If A4 is greater than B2 OR A4 is less than B2 plus 60 (days), then format the cell, otherwise do nothing. |
=NOT(A5>B2) |
If A5 is NOT greater than B2, format the cell, otherwise do nothing. In this case A5 is greater than B2, so the result will return FALSE. If you were to change the formula to =NOT(B2>A5) it would return TRUE and the cell would be formatted. |
Note: A common error is to enter your formula into Conditional Formatting without the equals sign (=). If you do this you’ll see that the Conditional Formatting dialog will add the equals sign and quotes to the formula — =»OR(A4>B2,A4<B2+60)», so you’ll need to remove the quotes before the formula will respond properly.
Need more help?
See also
You can always ask an expert in the Excel Tech Community or get support in the Answers community.
Learn how to use nested functions in a formula
IF function
AND function
OR function
NOT function
Overview of formulas in Excel
How to avoid broken formulas
Detect errors in formulas
Keyboard shortcuts in Excel
Logical functions (reference)
Excel functions (alphabetical)
Excel functions (by category)
The AND Function in excel is a logical function that tests multiple conditions and returns “true” or “false” depending on whether they are met or not. The formula of AND function is “=AND(logical1,[logical2]…),” where “logical1” is the first condition to evaluate.
Table of contents
- AND Function in Excel
- Syntax of the AND Function
- The Characteristics of AND Function
- The Output of AND Function
- How to Use AND Function in Excel?
- Example #1–AND Function
- Example #2–AND Function With Nested IF Function
- Example #3–AND Function With Nested IF Function
- Nesting of AND Function in Excel
- Example #4–Nested AND Function
- Limitations of AND Function
- Frequently Asked Questions
- Recommended Articles
Syntax of the AND Function
The syntax is stated as follows:
The function accepts the following arguments:
- Logical 1: This is the first condition or logical value to evaluate.
- Logical 2: This is the second condition or logical value to evaluate.
The “logical 1” is a mandatory argument and “logical 2” is an optional argument.
The Characteristics of AND Function
- It returns “true” if all conditions or logical values evaluate to true.
- It returns “false” if any of the conditions or logical values evaluates to false.
- It can have more logical values depending on the situation and the requirement.
- It treats the value zero as “false” and all non-zero values as “true” while evaluating numbers.
- It ignores empty cells provided as an argument.
- It is often used in combination with other Excel functionsExcel functions help the users to save time and maintain extensive worksheets. There are 100+ excel functions categorized as financial, logical, text, date and time, Lookup & Reference, Math, Statistical and Information functions.read more like IF, OR, and so on.
The Output of AND Function
The output in different situations is given as follows:
The output while evaluating numbers is given as follows:
How to Use AND Function in Excel?
It is easy to use the AND function. Let us understand its working with the help of a few examples.
You can download this AND Function Excel Template here – AND Function Excel Template
Example #1–AND Function
There are three levels and ten players in a game. To be a winner, a player has to clear all three levels. The player loses if he/she fails in any of the three levels.
The performance of the players in different levels is given in the following table. We are required to determine the winner.
We apply AND formula in column E.
The output of the formula appears in column E.
Player 2 and player 10 have cleared all the levels. Since all the logical conditions for these two players are met, the AND function gives the output “true.”
The rest of the players were unable to clear all three levels. If any of the levels is not cleared, the AND function returns “false.”
Example #2–AND Function With Nested IF Function
Let us consider the following example.
We have the marks (in percentage) of ten students in a school. We have to determine the grade obtained by each student according to the criteria given.
A student obtains “A+” if he/she scores more than 90%. If the percentage is greater than or equal to 80% but less than or equal to 90%, grade “A” is given.
If the percentage is less than 40%, the student fails. Likewise, the grades for the different percentages are given in the following table.
We apply the following formula.
“=IF(B2>90,”A+”,IF(AND(B2<=90,B2>80),”A”,IF(AND(B2<=80,B2>75),”B+”,IF(AND(B2<=75,B2>70),”B”,IF(AND(B2<=70,B2>60),”C+”,IF(AND(B2<=60,B2>50),”C”,IF(AND(B2<=50,B2>40),”D”,”FAIL”)))))))”
We use the nested IF functionIn Excel, nested if function means using another logical or conditional function with the if function to test multiple conditions. For example, if there are two conditions to be tested, we can use the logical functions AND or OR depending on the situation, or we can use the other conditional functions to test even more ifs inside a single if.read more with multiple AND functions to compute the grades. The latter allows testing two conditions together.
The syntax of the IF function is stated as follows:
“=IF(logical_test,[value_if_true],[value_if_false])”
The IF function returns “true” if the condition is met, else returns “false.”
The first logical test is “B2>90.” If this condition is “true,” grade “A+” is assigned. If this condition is “false,” the IF function evaluates the next condition.
The next logical testA logical test in Excel results in an analytical output, either true or false. The equals to operator, “=,” is the most commonly used logical test.read more is “B2<=90, B2>80.” If this condition is “true,” grade “A” is assigned. If this condition is “false,” the next statement is evaluated. Likewise, the IF function tests every condition given in the formula.
The last logical test is “B2<=50, B2>40.” If this condition is “true,” grade “D” is assigned, else the student fails.
We apply the formula to all categories of students, as shown in the following image.
The output of the formula is shown in the succeeding image.
Example #3–AND Function With Nested IF Function
The name of employees and the sales revenueSales revenue refers to the income generated by any business entity by selling its goods or providing its services during the normal course of its operations. It is reported annually, quarterly or monthly as the case may be in the business entity’s income statement/profit & loss account.read more generated by them for an organization are shown in the succeeding image. Every employee is given a monetary incentive depending on the total sales made by him/her.
We have to calculate the incentives of all the employees based on their performance.
The incentive criteria followed by the organization is given in the succeeding table.
We apply the following formula.
“=IF(AND(B2>=3000),400,IF(AND(B2>=2000,B2<3000),200,IF(AND(B2>=1500,B2<2000),150,IF(AND(B2>=1000,B2<1500),100,0))))”
We use multiple IFs In Excel, multiple IF conditions are IF statements that are contained within another IF statement. They are used to test multiple conditions at the same time and return distinct values. Additional IF statements can be included in the ‘value if true’ and ‘value if false’ arguments of a standard IF formula.read moreand multiple AND functions to calculate the incentives received by all the employees, as shown in the following table.
Roman generates sales revenue of $3000. So, he receives an incentive amount of $400.
The revenue generated by David and Tom is $500 and $600, respectively. To be eligible for an incentive, minimum sales of $1000 is required. Hence, they do not get any incentive.
Nesting of AND Function in Excel
A nested function refers to using a function inside another Excel function. In Excel, the nesting of functions up to 64 levels is allowed.
Example #4–Nested AND Function
We have a list of candidates who wish to join the Army subject to certain conditions. The eligibility criteria are stated as follows:
- The age should be greater than or equal to 18, but less than 35 years.
- The height should be greater than 167 cm.
- The eyesight should be normal.
- The candidate must have completed the long-run task.
We need to find out the candidates who are eligible for joining the Army.
To evaluate the candidates on the given parameters, we use the nested AND function.
We apply the following formula.
“=AND(B2=”Normal”,C2>167,D2=”Successful”,AND(E2>=18,E2<35))”
We evaluate multiple logical conditions simultaneously. We also check whether the age is within the prescribed limit or not. So, we use the AND function inside another AND function.
The output of the formula is shown in the succeeding image.
The candidates Ralph, Alex, and Scott pass the selection criteria. Hence, their eligibility output (in column F) is “true.” The remaining candidates are not eligible for joining the Army.
Limitations of AND Function
The limitations are listed as follows:
- With Excel 2007 onwards, the AND function can test up to 255 arguments given that the length of the formula does not exceed 8,162 characters.
- In Excel 2003 and previous versions, the AND function can test up to 30 arguments given that the length of the formula does not exceed 1,024 characters.
- The AND function returns “#VALUE! error#VALUE! Error in Excel represents that the reference cell the user has either entered an incorrect formula or used a wrong data type (mostly numerical data). Sometimes, it is difficult to identify the kind of mistake behind this error.read more” if logical conditions are passed as text or if none of the arguments evaluates to a logical value.
- The AND function returns “#VALUE! error” if all the arguments provided are empty cells.
The following two images show the output of the AND function when an empty cell and a text string is provided as an argument.
Frequently Asked Questions
#1 – When should the AND function of Excel be used
#2 – How is the AND function used with the OR function in Excel?
The OR function helps compare two values or statements. The AND function is combined with the OR function by the following formulas:
“=AND(OR(Condition1,Condition2),Condition3)”
“=AND(OR(Condition1,Condition2),OR(Condition3,Condition4)”
“=OR(AND(Condition1,Condition2),Condition3)”
“=OR(AND(Condition1,Condition2),AND(Condition3,Condition4))”
#3 – What is the difference between AND, IF, and OR functions in Excel?
The difference between the three functions is stated as follows:
– The AND function helps evaluate multiple conditions at the same time. It returns “true” when all conditions are true; otherwise, it returns “false.”
– The IF function helps compare the value with the result expected by the user. It returns specific values for the “true” and “false” outcomes.
– The OR function helps compare two values or two statements. It returns “true” when at least one of the specified conditions is met. It returns “false” if all the logical values evaluate to false.
- The AND function tests multiple conditions and returns “true” or “false” depending upon whether they are met or not.
- The AND function returns “true” if all conditions evaluate to true and returns “false” if any of the conditions evaluates to false.
- The AND function treats the value zero as “false.”
- The AND function can test up to 255 arguments in the latest versions of Excel.
- The AND function returns “#VALUE! error” if logical conditions are passed as a text.
- The formula of the IF function is “=IF(logical_test,[value_if_true],[value_if_false]).”
Recommended Articles
This has been a guide to AND Function in Excel. Here we discuss how to use AND Formula in Excel along with examples and downloadable excel templates. You may also look at these useful functions in Excel –
- Excel Pivot Table Add ColumnThe pivot table add column helps to add a new column in a pivot table.read more
- Excel Convert FunctionAs the word itself, the Excel CONVERT function defines that it can convert the numbers from one measurement system to another measurement system.read more
- VBA Boolean Data TypeBoolean is an inbuilt data type in VBA used for logical references or logical variables. The value this data type holds is either TRUE or FALSE and is used for logical comparison. The declaration of this data type is similar to all the other data types.read more
- IF AND Formula in ExcelThe IF AND excel formula is the combination of two different logical functions often nested together that enables the user to evaluate multiple conditions using AND functions. Based on the output of the AND function, the IF function returns either the “true” or “false” value, respectively.
read more
Purpose
Test multiple conditions with AND
Return value
TRUE if all arguments evaluate TRUE; FALSE if not
Usage notes
The AND function is used to check more than one logical condition at the same time, up to 255 conditions, supplied as arguments. Each argument (logical1, logical2, etc.) must be an expression that returns TRUE or FALSE or a value that can be evaluated as TRUE or FALSE. The arguments provided to the AND function can be constants, cell references, arrays, or logical expressions.
The purpose of the AND function is to evaluate more than one logical test at the same time and return TRUE only if all results are TRUE. For example, if A1 contains the number 50, then:
=AND(A1>0,A1>10,A1<100) // returns TRUE
=AND(A1>0,A1>10,A1<30) // returns FALSE
The AND function will evaluate all values supplied and return TRUE only if all values evaluate to TRUE. If any value evaluates to FALSE, the AND function will return FALSE. Note: Excel will evaluate any number except zero (0) as TRUE.
Both the AND function and the OR function will aggregate results to a single value. This means they can’t be used in array operations that need to deliver an array of results. To work around this limitation, you can use Boolean logic. For more information, see: Array formulas with AND and OR logic.
Examples
To test if the value in A1 is greater than 0 and less than 5, you can use AND like this:
=AND(A1>0,A1<5)
You can embed the AND function inside the IF function. Using the above example, you can supply AND as the logical_test for the IF function like so:
=IF(AND(A1>0,A1<5), "Approved", "Denied")
This formula will return «Approved» only if the value in A1 is greater than 0 and less than 5.
You can combine the AND function with the OR function. The formula below returns TRUE when A1 > 100 and B1 is «complete» or «pending»:
=AND(A1>100,OR(B1="complete",B1="pending"))
See below for many more examples of how the AND function can be used.
Notes
- The AND function is not case-sensitive.
- The AND function does not support wildcards.
- Text values or empty cells supplied as arguments are ignored.
- The AND function will return #VALUE if no logical values are found or created during evaluation.
In this article, we will learn How to use the AND function in Excel.
What is AND criteria ?
In Excel, we extract results based on the given criteria. For Example we need to extract the list of employees who are married and have salaries above half a million dollars per annum. The above criteria can be more difficult when there are more than 2 criterias. So Let’s learn the AND function which checks each criteria and returns only and only if all stated criteria stands true. Returns False if any of the conditions is false. Use the AND function and the IF function along with AND function to get customized results for the required result.
AND Function in Excel
AND function returns TRUE or FALSE. Multiple criterias to match is obtained using the AND function. Mention the criterias inside the AND function separated using the ( , ).
Syntax:
=AND(logical1, [logical2], [logical3], …)
logical1 : first criteria
logical2 : second criteria and further criteria goes on
Example :
All of these might be confusing to understand. Let’s understand how to use the function using an example. Here we have few Examples to test multiple conditions and statements of AND function.
Use the formula in E2 cell.
Press Enter
It returns True as all the statements return True.
There are some default AND Excel statements
- All numbers except 0 are considered True.
- 0 is considered as False.
- True is True and False is False.
Apply the formula in other cells using Ctrl + D taking the first applied cells till the cell you wish to copy formula.
In the E2 cell, we applied the formula
We test the 4 conditions in this AND formula. All conditions return 4 which is considered True is Excel. If all conditions return positive numbers and any of it returns 0 then the formula will return False.
You can check less than or greater than condition on numbers. OR function can also be used along with many functions like IF, AND and many more.
IF — AND Function in Excel
IF function: You know how IF function in Excel works. It takes a boolean expression as the first argument and returns one expression IF TRUE and another if FALSE. Learn more about The Excel IF Function.
=IF(TRUE or FALSE, statement if True, statement if false)
AND Function : Checks multiple conditions. Returns TRUE only if all conditions are TRUE else returns FALSE.
=AND(condition1, condition2,….) ==> TRUE/FALSE
In the end, AND function provides IF function TRUE or FALSE argument and based on that IF prints the result.
Example
Here We have a list of Scores and We need to know under which criteria it lies.
Here multiple criterias are needed to satisfy. Use the formula to match the given criteria table
Formula:
=IF(AND(B3 > 50, B3 < 60), «Below Average»,IF(AND(B3 > 60, B3 < 90),»Average»,IF(AND(B3 > 90,B3< 100),»Above Average»,»Top Score»)))
Copy the formula in other cells, select the cells taking the first cell where the formula is already applied, use shortcut key Ctrl + D
We got the Results corresponding to the Scores.
You can use IF and AND function to meet multiple conditions in a single formula.
Here are all the observational notes using the AND function in Excel
Notes :
- Make sure each condition in the formula works fine for the number values before using for all the other values.
- Operations like equals to ( = ), less than equal to ( <= ), greater than ( > ) or not equals to ( <> ) can be performed within a formula applied, with numbers only.
Hope this article about How to use the AND function in Excel is explanatory. Find more articles on using logical values and related Excel formulas here. If you liked our blogs, share it with your friends on Facebook. And also you can follow us on Twitter and Facebook. We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write to us at info@exceltip.com.
Related Articles :
How to Count Cells That Contain This Or That in Excel in Excel : To cells that contain this or that, we can use the SUMPRODUCT function. Here’s how you do those calculations.
How to use nested IF function : nested IF function operates on data having multiple criteria. The use of repeated IF function is nested IF excel formula.
SUMIFS using AND-OR logic : Get the sum of numbers having multiple criteria applied using logic AND-OR excel function.
COUNTIFS With OR For Multiple Criteria : Count cells having multiple criteria match using the OR function. To put an OR logic in COUNTIFS function you will not need to use the OR function.
Using the IF with AND / OR Functions in Microsoft Excel : These logical functions are used to carry out multiple criteria calculations. With IF the OR and AND functions are used to include or exclude matches.
IF with OR function : Implementation of logic IF function with OR function to extract results having criteria in excel data.
IF with AND function : Implementation of logic IF function with AND function to extract results having criteria in Excel.
Popular Articles :
How to use the IF Function in Excel : The IF statement in Excel checks the condition and returns a specific value if the condition is TRUE or returns another specific value if FALSE.
How to use the VLOOKUP Function in Excel : This is one of the most used and popular functions of excel that is used to lookup value from different ranges and sheets.
How to use the SUMIF Function in Excel : This is another dashboard essential function. This helps you sum up values on specific conditions.
How to use the COUNTIF Function in Excel : Count values with conditions using this amazing function. You don’t need to filter your data to count specific values. Countif function is essential to prepare your dashboard.