How to use and or formula in excel

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.

Examples of using IF with AND, OR and NOT to evaluate numeric values and text

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.

Examples of using IF with 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.

Example of the Evaluate Formula Wizard

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.

Conditional Formatting > Edit Rule dialog showing the Formula method

Using the earlier Dates example, here is what the formulas would be.

Example of using AND, OR and NOT as Conditional Formatting tests

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?

Connect with an expert. Learn from live instructors.​​​​​​​

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)

Skip to content

Excel AND + OR Functions: Full Guide (with IF Formulas)

Excel AND + OR Functions: Full Guide (with IF Formulas)

The AND and OR functions returns True or False if certain conditions are met.

Combined with other functions, like IF, that enables multiple criteria logic in your formulas.

In this guide, I’ll walk you through all of this, step-by-step 👍🏼

If you want to tag along, download the sample workbook here.

We use the data in the following table to learn how to apply OR and AND function with the IF function in excel.

Example to apply OR function and AND function with the IF function

The OR function

The OR function is one of the most important logical functions in excel 😯

The OR function in Excel returns True if at least one of the criteria evaluates to true.

If all the arguments evaluate as False, then the OR function returns False.

The syntax of the OR function in Excel is OR(logical1, [logical2], …).

Assume that employees are eligible for an incentive if they achieve a value or volume target of 75% or more 🏆

Let’s try OR function for the above example.

  1. Enter an equal sign and select the OR function.

You will see below in the formula bar.

=OR(

Select the OR function Excel
  1. Supply the first logical value to evaluate as the first argument.

You can write logical values to test using logical operators.

In this case, we want to first test, whether the value target achievement is greater than or equal to 75%.

So, we can give the cell reference and write the condition >=75%.

Now the formula is,

=OR(B3>=75%

Entering logical values - 1st logical value
  1. Enter a comma and enter the 2nd logical value for the logical test.

Then, we enter the logical value for the volume target.

Now, the updated formula is;

=OR(B3>7=75%,C3>=75%

Entering logical values - 2nd logical value
  1. Close the parentheses and press enter.

The below Excel formula evaluates arguments.

=OR(B3>7=75%,C3>=75%)

Then returns true if at least one of the value or volume target achievements is greater than or equal to 75%. If both value and volume target achievements are below 75%, the OR function returns False.

The OR function evaluate arguments for two values and return true or false

Pro Tip:

Now you have learned, the OR function returns True even when more than one condition evaluates to “True”.

Do you think you have to combine the OR function with the NOT function?

No. Excel has a simple solution 😜

You have to use the XOR function.

Apply the below XOR formula to the above example and see how the results are changing.

=XOR(B3>7=75%,C3>=75%)

Using the XOR instead of OR function

You can see that Mary’s result is “False” as her achievements are not satisfying the one and only condition.

OR function IF formula example

Isn’t it boring to see only “True or false” values? 🥱

Don’t you like to get something other than True or False values? 👍

You just need to combine the OR function with the IF function in Excel.

Let’s say, we want the function to return “Eligible” if at least one of the value or volume target achievements is greater than or equal to 75%.

Also, return “Not eligible”, if both value and volume target achievements are less than 75%.

  1. Enter the equal sign and select the IF function.

Now, the formula bar will show;

Selecting the IF function to apply the OR function in Excel
  1. Enter the OR function that we have learned in the previous section.

The updated formula should be like this.

=IF(OR(B3>=75%,C3>=75%)

Insert the OR function as the test argument of the IF function in Excel.
  1. Enter the specific value you want the function to return when the result of the logical test is True.

In this case, we want to get “Eligible”.

So, we enter the word eligible within quotes.

Now, the formula is;

=IF(OR(B3>=75%,C3>=75%),”Eligible”

Providing the value to be returned if the logical test result is True.

If you want to enter text values for the arguments, you have to enter them within quotes. However, you don’t need to enter True or false values within quotes. Excel automatically evaluates arguments provided with true or false values.

Kasper Langmann, Microsoft Office Specialist
  1. Enter the specific value you want the function to return when the result of the logical test is False.

In this case, we want to get “Not Eligible”.

Now, the updated formula is;

=IF(OR(B3>=75%,C3>=75%),”Eligible”,”Not Eligible”

Providing the value to be returned if the logical test result is False.
  1. Close the parentheses and press “Enter”.
Combining IF and OR functions in Excel to get the expected value.

The AND function

AND function is another important logical function in excel.

This function returns true all of the multiple criteria are true.

Otherwise, the AND function returns False.

The syntax of the AND function in Excel is AND(logical1, [logical2], …).

Say that employees are entitled to an incentive if they achieve more than or equal to 75% for both the value target and volume target.

Let’s try AND function for the above example.

  1. Enter an equal sign and select the AND function.

You will see below in the formula bar.

=AND(

Entering the AND function in Excel.
  1. Enter all logical values to test using logical operators.

So, you can enter the following formula.

=AND(B3>=75%,C3>=75%

Entering arguments to test multiple conditions
  1. Close the parentheses and press “Enter”.
The AND function example

You can see that the AND function returns true only when both the value and volume target achievements exceed or are equal to 75% 🥳

However, there is limited usage of AND function if we do not combine it with other functions in Excel 🤔

Let’s see an example with a combination of the IF function and AND function.

AND function IF formula example

Let’s say, we want the function to return “Eligible”, only when both value and volume target achievements are more than or equal to 75%.

Otherwise, we want to get “Not eligible”

  1. Enter the equals sign and select the IF function.

Now, the formula bar will show;

Selecting the IF function
  1. Enter the AND function that we have learned in the previous section.

The updated formula should be like this.

=IF(AND(B3>=75%,C3>=75%)

  1. Enter the specific value you want the function to return when the result of the logical test is True.

In this case, we want to get “Eligible”.

So, we enter the word eligible within quotes.

Now, the formula is;

=IF(AND(B3>=75%,C3>=75%),”Eligible”

Providing the value to be returned if the logical test result is True - Excel AND function
  1. Enter the specific value you want the function to return when the result of the logical test is False.

In this case, we want to get “Not Eligible”.

Now, the updated formula is;

=IF(AND(B3>=75%,C3>=75%),”Eligible”,”Not Eligible”

Providing the value to be returned if the logical test result is False - Excel AND function
  1. Close the parentheses and press “Enter”.
Combining IF and AND functions in Excel to get the desired result.

You can see that we get “Eligible” only when all of the multiple conditions are True. Otherwise, functions will return false 😍

Any empty cells in a logical function’s argument are ignored.

Kasper Langmann, Microsoft Office Specialist
Any empty cells in a logical function's argument are ignored

That’s it – Now what?

Well done 👏🏻

Now you know how to use the OR and AND functions in Excel.

Using the above examples, you have learned that OR and AND functions are more powerful when we combine them with other Excel functions 💪🏻

To learn more about other important functions such as IF, SUMIF, and VLOOKUP functions, all you need to do is enroll in my free 30-minute online Excel course.

Other resources

When you are using OR and AND functions, it is extremely important to use logical operators correctly ⚡

Read our article about logical operators, if you want to refresh your knowledge about them.

Also, Read our articles about the IF function, nested IF function, and SUMIF function and apply OR and AND functions more effectively 🥳

Frequently asked questions

You can enter 2 conditions or more for the logical test argument of the IF function using the following formulas.

If you want to satisfy,

  • Both conditions – use the AND function.
  • At least one condition – use the OR function
  • Only one condition – use the XOR function.

Yes. We can use multiple logical functions with the IF function in Excel.

You can combine OR and AND functions to evaluate the arguments appropriately.

Kasper Langmann2023-02-23T11:04:48+00:00

Page load link

To write an IF, AND, OR array formula in Excel 365, we must use the arithmetic operators * (multiplication) and + (addition). Why it’s so?

If we take the logical AND, OR with the IF in Excel 365 to spill the result, we won’t get our expected result.

I mean, such a formula won’t support a range/array in evaluation. Even if it supports, it won’t return an array result.

So we will replace the AND logical operator with the * (multiplication) and OR with the + (addition) arithmetic operators.

Coding the formula with the said two operators is very simple and easily readable.

I think I can convince you the same with the examples below.

Example to IF, AND, OR in Excel 365 (Non-Array Formula)

Imagine a user played a game three times, and we have recorded his scores out of 100 in cells A2, B2, and C2.

We want to perform the following three logical tests on the scores individually.

  1. If all scores are >=80, return OK.
  2. If any of the two scores are >=80, return OK.
  3. Finally, if any of the scores is >=80, return OK.

Logical Tests Using IF, AND, OR Functions

In Excel, we can perform the above three logical tests as follows.

1. E2 (If all scores are >=80, return OK)

=IF(AND(A2>=80,B2>=80,C2>=80),"OK","NOT OK")

I have used the AND function with IF in the above Excel formula to test if all the three logical tests return TRUE.

2. F2 (If any of the two scores are >=80, return OK)

We must use the following logic (two parts) to test if any two logical tests return TRUE.

AND Part:-

a) Value 1>=80 and value 2>=80.

b) Value 1>=80 and value 3>=80.

c) Value 2>=80 and value 3>=80.

OR Part:-

a) The OR evaluates to TRUE if any two of the above three AND tests return TRUE.

So the formula will be as follows.

=IF(OR(AND(A2>=80,B2>=80),AND(A2>=80,C2>=80),AND(B2>=80,C2>=80)),"OK","NOT OK")

It is an example of the IF, AND, OR logical test in Excel.

3. G2 (if any of the scores is >=80, return OK)

=IF(OR(A2>=80,B2>=80,C2>=80),"OK","NOT OK")

Here I have used the OR function with IF to test if any of the three logical tests return TRUE.

As I have already mentioned, we can’t write an IF, AND, OR array formula as above in Excel 365.

Logical Tests Using IF, *, + Formula

Let’s substitute the above three formulas by replacing AND, OR with multiplication and addition.

But that’s not enough. Then?

The below formulas are self-explanatory.

1. E2 Formula

=IF((A2:A8>=80)*(B2:B8>=80)*(C2:C8>=80),"OK","NOT OK")

How the multiplication replaces the logical function OR above?

Each test in the formula returns either TRUE or FALSE. If all the criteria are met, it will be =IF((TRUE*TRUE*TRUE),"OK","NOT OK").

We can even replace the multiplication operator here with addition.

=IF((A2:A8>=80)+(B2:B8>=80)+(C2:C8>=80)>2,"OK","NOT OK")

Please remember that the value of TRUE is 1, and FALSE is 0.

2. F2 Formula

=IF((A2:A8>=80)+(B2:B8>=80)+(C2:C8>=80)>1,"OK","NOT OK")

3. G2 Formula

=IF((A2:A8>=80)+(B2:B8>=80)+(C2:C8>=80)>0,"OK","NOT OK")

Above I have tried to simplify the use of the logical operators within the IF function.

Now let’s open an Excel Spreadsheet and enter the scores of multiple players in the range A2:C8 as below.

IF, AND, OR Array Formula in Excel 365

So the values to evaluate are in cell range A2:C8.

I have inserted the following three IF, AND, OR array formulas in cells E2, F2, and G2, respectively.

1. E2 Array Formula

=IF((A2:A8>=80)*(B2:B8>=80)*(C2:C8>=80),"OK","NOT OK")

2. F2 Array Formula

=IF((A2:A8>=80)+(B2:B8>=80)+(C2:C8>=80)>1,"OK","NOT OK")

3. G2 Array Formula

=IF((A2:A8>=80)+(B2:B8>=80)+(C2:C8>=80)>0,"OK","NOT OK")

If any of the above formulas return #SPILL!, please empty the cells down in that column.

Nested IF, AND, OR Combination in Excel 365

I want to assign grades based on the scores above.

In that case, we may require to write a nested IF, AND, OR combination array formula in Excel 365.

Here is how.

In the above example, we have used three formulas for the below three logical tests.

  • If all scores are >=80, return OK.
  • If any of the two scores are >=80, return OK.
  • Finally, if any of the scores is >=80, return OK.

There each test returns OK or NOT OK.

Instead of that, here, I want the tests to return GR-1, GR-2, and GR-3.

  • If all scores are >=80, return GR-1.
  • If any of the two scores are >=80, return GR-2.
  • Finally, if any of the scores is >=80, return GR-3.

For that, we should combine the above three IF, AND, OR Array Formulas.

How?

In the E2 formula, replace “OK” with “GR-1” and “NOT OK” with the F2 formula.

In that combined (E2 and F2) formula, replace “OK” with “GR-2” and “NOT OK” with the G2 formula.

Then, in the combined E2, F2, and G2 formula, replace “OK” with “GR-3” and replace “NOT OK” with “F.”

Here it is.

Nested IF, AND, OR Combination in Excel 365

=IF(
     (A2:A8>=80)*(B2:B8>=80)*(C2:C8>=80),"GR-1",
     IF(
        (A2:A8>=80)+(B2:B8>=80)+(C2:C8>=80)>1,"GR-2",
        IF(
           (A2:A8>=80)+(B2:B8>=80)+(C2:C8>=80)>0,"GR-3","F"
        )
     )
)

We can call it a nested IF, AND, OR combination array formula.

Related:- How to Use the IFS Function in Excel 365.

excel logo

Logical functions are some of the most popular and useful in Excel. They can test values in other cells and perform actions dependent upon the result of the test. This helps us to automate tasks in our spreadsheets.

How to Use the IF Function

The IF function is the main logical function in Excel and is, therefore, the one to understand first. It will appear numerous times throughout this article.

Let’s have a look at the structure of the IF function, and then see some examples of its use.

The IF function accepts 3 bits of information:

=IF(logical_test, [value_if_true], [value_if_false])
  • logical_test: This is the condition for the function to check.
  • value_if_true: The action to perform if the condition is met, or is true.
  • value_if_false: The action to perform if the condition is not met, or is false.

Comparison Operators to Use with Logical Functions

When performing the logical test with cell values, you need to be familiar with the comparison operators. You can see a breakdown of these in the table below.

Comparison operators for logical functions

Now let’s look at some examples of it in action.

IF Function Example 1: Text Values

In this example, we want to test if a cell is equal to a specific phrase. The IF function is not case-sensitive so does not take upper and lower case letters into account.

The following formula is used in column C to display “No” if column B contains the text “Completed” and “Yes” if it contains anything else.

=IF(B2="Completed","No","Yes")

IF function to test text values

Although the IF function is not case sensitive, the text must be an exact match.

IF Function Example 2: Numeric Values

The IF function is also great for comparing numeric values.

In the formula below we test if cell B2 contains a number greater than or equal to 75. If it does, then we display the word “Pass,” and if not the word “Fail.”

=IF(B2>=75,"Pass","Fail")

If condition with numeric values

The IF function is a lot more than just displaying different text on the result of a test. We can also use it to run different calculations.

In this example, we want to give a 10% discount if the customer spends a certain amount of money. We will use £3,000 as an example.

=IF(B2>=3000,B2*90%,B2)

Conditional formula by using the IF function

The B2*90% part of the formula is a way that you can subtract 10% from the value in cell B2. There are many ways of doing this.

What’s important is that you can use any formula in the value_if_true or value_if_false sections. And running different formulas dependent upon the values of other cells is a very powerful skill to have.

IF Function Example 3: Date Values

In this third example, we use the IF function to track a list of due dates. We want to display the word “Overdue” if the date in column B is in the past. But if the date is in the future, calculate the number of days until the due date.

The formula below is used in column C. We check if the due date in cell B2 is less than today’s date (The TODAY function returns today’s date from the computer’s clock).

=IF(B2<TODAY(),"Overdue",B2-TODAY())

Testing if dates are due

What are Nested IF Formulas?

You may have heard of the term nested IFs before. This means that we can write an IF function within another IF function. We may want to do this if we have more than two actions to perform.

One IF function is capable of performing two actions (the value_if_true and value_if_false ). But if we embed (or nest) another IF function in the value_if_false section, then we can perform another action.

Take this example where we want to display the word “Excellent” if the value in cell B2 is greater than or equal to 90, display “Good” if the value is greater than or equal to 75, and display “Poor” if anything else.

=IF(B2>=90,"Excellent",IF(B2>=75,"Good","Poor"))

We have now extended our formula to beyond what just one IF function can do. And you can nest more IF functions if necessary.

Notice the two closing brackets on the end of the formula—one for each IF function.

There are alternative formulas that can be cleaner than this nested IF approach. One very useful alternative is the SWITCH function in Excel.

The AND and OR functions are used when you want to perform more than one comparison in your formula. The IF function alone can only handle one condition, or comparison.

Take an example where we discount a value by 10% dependent upon the amount a customer spends and how many years they have been a customer.

On their own, the AND and OR functions will return the value of TRUE or FALSE.

The AND function returns TRUE only if every condition is met, and otherwise returns FALSE. The OR function returns TRUE if one or all of the conditions are met, and returns FALSE only if no conditions are met.

These functions can test up to 255 conditions, so are certainly not limited to just two conditions like is demonstrated here.

Below is the structure of the AND and OR functions. They are written the same. Just substitute the name AND for OR. It is just their logic which is different.

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

Let’s see an example of both of them evaluating two conditions.

AND Function example

The AND function is used below to test if the customer spends at least £3,000 and has been a customer for at least three years.

=AND(B2>=3000,C2>=3)

AND function in Excel

You can see that it returns FALSE for Matt and Terry because although they both meet one of the criteria, they need to meet both with the AND function.

OR Function Example

The OR function is used below to test if the customer spends at least £3,000 or has been a customer for at least three years.

=OR(B2>=3000,C2>=3)

The OR logical function

In this example, the formula returns TRUE for Matt and Terry. Only Julie and Gillian fail both conditions and return the value of FALSE.

Using AND and OR with the IF Function

Because the AND and OR functions return the value of TRUE or FALSE when used alone, it’s rare to use them by themselves.

Instead, you’ll typically use them with the IF function, or within an Excel feature such as Conditional Formatting or Data Validation to perform some retrospective action if the formula evaluates to TRUE.

In the formula below, the AND function is nested inside the IF function’s logical test. If the AND function returns TRUE then 10% is discounted from the amount in column B; otherwise, no discount is given and the value in column B is repeated in column D.

=IF(AND(B2>=3000,C2>=3),B2*90%,B2)

Excel formula with IF and AND functions

The XOR Function

In addition to the OR function, there is also an exclusive OR function. This is called the XOR function. The XOR function was introduced with the Excel 2013 version.

This function can take some effort to understand, so a practical example is shown.

The structure of the XOR function is the same as the OR function.

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

When evaluating just two conditions the XOR function returns:

  • TRUE if either condition evaluates to TRUE.
  • FALSE if both conditions are TRUE, or neither condition is TRUE.

This differs from the OR function because that would return TRUE if both conditions were TRUE.

This function gets a little more confusing when more conditions are added. Then the XOR function returns:

  • TRUE if an odd number of conditions return TRUE.
  • FALSE if an even number of conditions result in TRUE, or if all conditions are FALSE.

Let’s look at a simple example of the XOR function.

In this example, sales are split over two halves of the year. If a salesperson sells £3,000 or more in both halves then they are assigned Gold standard. This is achieved with an AND function with IF like earlier in the article.

But if they sell £3,000 or more in either half then we want to assign them Silver status. If they don’t sell £3,000 or more in both then nothing.

The XOR function is perfect for this logic. The formula below is entered into column E and shows the XOR function with IF to display  “Yes” or “No” only if either condition is met.

=IF(XOR(B2>=3000,C2>=3000),"Yes","No")

The XOR Function in Excel

The NOT Function

The final logical function to discuss in this article is the NOT function, and we have left the simplest for last. Although sometimes it can be hard to see the ‘real world’ uses of the function at first.

The NOT function reverses the value of its argument. So if the logical value is TRUE, then it returns FALSE. And if the logical value is FALSE, it will return TRUE.

This will be easier to explain with some examples.

The structure of the NOT function is;

=NOT(logical)

NOT Function Example 1

In this example, imagine we have a head office in London and then many other regional sites. We want to display the word “Yes” if the site is anything except London, and “No” if it is London.

The NOT function has been nested in the logical test of the IF function below to reverse the TRUE result.

=IF(NOT(B2="London"),"Yes","No")

This can also be achieved by using the NOT logical operator of <>. Below is an example.

=IF(B2<>"London","Yes","No")

NOT Function Example 2

The NOT function is useful when working with information functions in Excel. These are a group of functions in Excel that check something, and return TRUE if the check is a success, and FALSE if it is not.

For example, the ISTEXT function will check if a cell contains text and return TRUE if it does and FALSE if it does not. The NOT function is helpful because it can reverse the result of these functions.

In the example below, we want to pay a salesperson 5% of the amount they upsell. But if they did not upsell anything, the word “None” is in the cell and this will produce an error in the formula.

The ISTEXT function is used to check for the presence of text. This returns TRUE if there is text, so the NOT function reverses this to FALSE. And the IF performs its calculation.

=IF(NOT(ISTEXT(B2)),B2*5%,0)

NOT function example 2

Mastering logical functions will give you a big advantage as an Excel user. To be able to test and compare values in cells and perform different actions based on those results is very useful.


This article has covered the best logical functions used today. Recent versions of Excel have seen the introduction of more functions added to this library, such as the XOR function mentioned in this article. Keeping up to date with these new additions will keep you ahead of the crowd.

READ NEXT

  • › How to Use an Advanced Filter in Microsoft Excel
  • › Functions vs. Formulas in Microsoft Excel: What’s the Difference?
  • › 13 Essential Excel Functions for Data Entry
  • › How to Group Worksheets in Excel
  • › How to Count Characters in Microsoft Excel
  • › How to Find the Function You Need in Microsoft Excel
  • › How to Use the IS Functions in Microsoft Excel
  • › BLUETTI Slashed Hundreds off Its Best Power Stations for Easter Sale

Функция OR (ИЛИ) в Excel используется для сравнения двух условий.

Содержание

  1. Что возвращает функция
  2. Синтаксис
  3. Аргументы функции
  4. Дополнительная информация
  5. Примеры использования функции OR (ИЛИ) в Excel
  6. Пример 1. Используем аргументы TRUE и FALSE в функции OR (ИЛИ)
  7. Пример 2. Используем ссылки на ячейки, содержащих TRUE/FALSE
  8. Пример 3. Используем условия с функцией OR (ИЛИ)
  9. Пример 4. Используем числовые значения с функцией OR (ИЛИ)
  10. Пример 5. Используем функцию OR (ИЛИ) с другими функциями

Что возвращает функция

Возвращает логическое значение TRUE (Истина), при выполнении условий сравнения в функции и отображает FALSE (Ложь), если условия функции не совпадают.

Синтаксис

=OR(logical1, [logical2],…) — английская версия

=ИЛИ(логическое_значение1;[логическое значение2];…) — русская версия

Аргументы функции

  • logical1 (логическое_значение1) — первое условие которое оценивает функция по логике TRUE или FALSE;
  • [logical2] ([логическое значение2]) — (не обязательно) это второе условие которое вы можете оценить с помощью функции по логике TRUE или FALSE.

Дополнительная информация

  • Функция OR (ИЛИ) может использоваться с другими формулами.

Например, в функции IF (ЕСЛИ) вы можете оценить условие и затем присвоить значение, когда данные отвечают условиям логики TRUE или FALSE. Используя функцию вместе с IF (ЕСЛИ), вы можете тестировать несколько условий оценки значений за раз.

Например, если вы хотите проверить значение в ячейке А1 по условию: “Если значение больше “0” или меньше “100” то… “ — вы можете использовать следующую формулу:

=IF(OR(A1>100,A1<0),”Верно”,”Неверно”) — английская версия

=ЕСЛИ(ИЛИ(A1>100;A1<0);»Верно»;»Неверно») — русская версия

  • Аргументы функции должны быть логически вычислимы по принципу TRUE или FALSE;
  • Текст и пустые ячейки игнорируются функцией;
  • Если вы используете функцию с не логически вычисляемыми значениями — она выдаст ошибку;
  • Вы можете тестировать максимум 255 условий в одной формуле.

Примеры использования функции OR (ИЛИ) в Excel

Пример 1. Используем аргументы TRUE и FALSE в функции OR (ИЛИ)

Функция OR (ИЛИ) в Excel

Вы можете использовать TRUE/FALSE в качестве аргументов. Если любой из них соответствует условию TRUE, функция выдаст результат TRUE. Если оба аргумента функции соответствуют условию FALSE, функция выдаст результат FALSE.

Telegram Logo Больше лайфхаков в нашем Telegram Подписаться

Она может использовать аргументы TRUE и FALSE в кавычках.

Пример 2. Используем ссылки на ячейки, содержащих TRUE/FALSE

Функция OR (ИЛИ) в Excel

Вы можете использовать ссылки на ячейки со значениями TRUE или FALSE. Если любое значение из ссылок соответствует условиям TRUE, функция выдаст TRUE.

Пример 3. Используем условия с функцией OR (ИЛИ)

Функция OR (ИЛИ) в Excel

Вы можете проверять условия с помощью функции OR (ИЛИ). Если любое из условий соответствует TRUE, функция выдаст результат TRUE.

Пример 4. Используем числовые значения с функцией OR (ИЛИ)

Функция OR (ИЛИ) в Excel

Число “0” считается FALSE в Excel по умолчанию. Любое число, выше “0”, считается TRUE (оно может быть положительным, отрицательным или десятичным числом).

Пример 5. Используем функцию OR (ИЛИ) с другими функциями

Вы можете использовать функцию OR (ИЛИ) с другими функциями для того, чтобы оценить несколько условий.

На примере ниже показано, как использовать функцию вместе с IF (ЕСЛИ):

Функция OR (ИЛИ) в Excel

На примере выше, мы дополнительно используем функцию IF (ЕСЛИ) для того, чтобы проверить несколько условий. Формула проверяет значение ячеек А2 и A3. Если в одной из них значение более чем “70”, то формула выдаст “TRUE”.

Понравилась статья? Поделить с друзьями:
  • How to use an before a word
  • How to use a word wall
  • How to use a word document
  • How to uppercase letter in word
  • How to update microsoft word