If combined with or 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)

Home / Excel Formulas / How to Combine IF and OR Functions in Excel

IF Function is one of the most powerful functions in excel. And, the best part is, that you can combine other functions with IF to increase its power.

Combining IF and OR functions is one of the most useful formula combinations in excel. In this post, I’ll show you why we need to combine IF and OR functions. And, why it’s highly useful for you.

Quick Intro

I am sure you have used both of these functions but let me give you a quick intro.

  • IF – Use this function to test a condition. It will return a specific value if that condition is true, or else some other specific value if that condition is false.
  • OR – Test multiple conditions. It will return true if any of those conditions is true, and false if all of those conditions are false.

The crux of both of the functions is IF function can test only one condition at a time. And, OR function can test multiple conditions but only return true/false. And, if we combine these two functions we can test multiple conditions with OR & return a specific value with IF.

How do IF and OR functions Work?

In the syntax of the IF function, have a logical test argument that we use to specify a condition to test.

IF(logical_test,value_if_true,value_if_false)

And, then it returns a value based on the result of that condition. Now, if we use OR function for that argument and specify multiple conditions for it.

how to combine if and or functions and replace logical argument with or

If any of the conditions is true OR will return true and IF will return the specific value. And, if none of the conditions is true OR with return FALSE IF will return another specific value. In this way, we can test more than one value with the IF function. Let’s get into some real-life examples.

Examples

Here I have a table with stock details of two warehouses. Now the thing is I want to update the status in the table.

how to combine if and or functions to get status in stock table

If there is no stock in both of the warehouses status should be “Out of Stock”. And, if there is stock in any of the warehouse status should be “In-Stocks”. So here I have to check two different conditions “Warehouse-1” & “Warehouse-2”.
And the formula will be.

=IF(OR(B2>0,C2>0),"In-Stock","Out of Stock")
how to combine if and or functions to get status in stock table insert formula

In the above formula, if there is a value greater than zero in any of the cells (B2 & C2) OR function will return true, and IF will return the value “In-Stock”. But, if both cells have zero then OR will return false, and IF will return the value “Out of Stock”.

Download Sample File

  • Ready

Last Words

Both of the functions are equally useful but when you combine them, you can use them in a better way. As I told you, by combining IF and Or functions you can test more than one condition. You can solve your two problems with this combination of functions.

And, if you want to Get Smarter than Your Colleagues check out these FREE COURSES to Learn Excel, Excel Skills, and Excel Tips and Tricks.

A1 and less than 10, return «OK». Otherwise, return nothing («»).

To return B1+10 when A1 is «red» or «blue» you can use the OR function like this:

Translation: if A1 is red or blue, return B1+10, otherwise return B1.

Translation: if A1 is NOT red, return B1+10, otherwise return B1.

IF cell contains specific text

Because the IF function does not support wildcards, it is not obvious how to configure IF to check for a specific substring in a cell. A common approach is to combine the ISNUMBER function and the SEARCH function to create a logical test like this:

For example, to check for the substring «xyz» in cell A1, you can use a formula like this:

Источник

OR Function in Excel

What is OR Function in Excel?

The OR function of Excel is used to test multiple conditions at the same time. A condition is an expression that evaluates to either “true” or “false” but not to both simultaneously. The OR function is categorized as a Logical function of Excel.

It returns either of the following outcomes:

  • True, if any of the conditions is true or all the conditions are true
  • False, if all the conditions are false

For example, the formula “=OR(2>4,8>5)” (ignore the double quotation marks) returns “true.” The first condition (2>4) evaluates to false, while the second condition (8>5) evaluates to true. Since one of the conditions is true, the final output is “true.”

A condition is supplied as an argument to the OR function. An argument can consist of numbers, text strings, cell references, formulas or Boolean values (true and false). The purpose of using the OR function is to assess whether any of the various conditions is met or not. It also facilitates multiple comparisons of data values.

Table of contents

Syntax of the OR Function of Excel

The syntax of the OR function in excel is given in the following image:

The OR function accepts the following arguments:

  • Logical1: This is the first condition to be tested.
  • Logical2: This is the second condition to be tested.

“Logical1” is required, while “logical2” and the subsequent “logical” arguments are optional.

Let us consider some examples to understand the working of the OR function of Excel. To know more about the nested OR function, refer to example #4 of this article.

Note 1: Each argument (condition) of the OR function must necessarily evaluate to either “true” or “false.” Moreover, each condition should consist of the relevant logical (or comparison) operator. There are six logical operators in Excel Logical Operators In Excel Logical operators in excel are also known as the comparison operators and they are used to compare two or more values, the return output given by these operators are either true or false, we get true value when the conditions match the criteria and false as a result when the conditions do not match the criteria. read more . These are “equal to” (=), “not equal to” (<>), “greater than” (>), “greater than or equal to” (>=), “less than” (

Example #2–Test Two Conditions Containing a mix of Numerical and Textual Values

Working on the dataset of example #1, we want to evaluate the following conditions together:

  • The value of cell A1 is equal to 45
  • The value of cell A2 is “Google.”

Use the OR function of Excel.

The steps to test the given conditions with the help of the OR function are listed as follows:

Step 1: Enter the following formula in cell C1.

We have inserted the appropriate logical operators in the given conditions. So, the first condition is A1=45 and the second condition is A2=“Google.”

Step 2: Press the “Enter” key. The output appears as “true” in cell C1.

In this example, the first condition is true as the value of cell A1 is equal to 45. The second condition is false as the value of cell A2 is not “Google.” Since one of the two conditions evaluate to true, the final output is “true.”

The formula and the output are shown in the following image.

Example #3–Test Three Conditions Containing a mix of Numerical and Textual Values

Working on the dataset of example #1, evaluate the following three conditions together:

  • The value of cell A1 is greater than or equal to 5
  • The value of cell A1 is equal to 35
  • The value of cell A2 is “e2esols.com.”

Use the OR function of Excel.

The steps to test the given conditions by using the OR function in excel are listed as follows:

Step 1: Insert the logical operators that fit the given conditions. So, enter the following formula in cell C1.

Here, the first, second, and third conditions are “A1>=5,” “A1=35,” and A2=“e2esols.com” respectively.

Step 2: Press the “Enter” key. The output in cell C1 is “true.”

The first condition evaluates to true because 45 (value of cell A1) is certainly greater than 5. The second condition is false as 45 is not equal to 35. The third condition is true as the value of cell A2 is “e2esols.com.”

So, two out of three conditions are true. Consequently, the final output is also “true.” Even if one of the three conditions had been true, the final output would still have been “true.”

The formula (entered in step 1) and the output are shown in the following image.

Example #4–Test Three Conditions With a Nested OR or Nested AND Within the IF Function

The succeeding table shows some random numbers in column A. In column B, the following three conditions are tested:

  • The value of cell A2 is less than 50
  • The value of cell A3 is not equal to 75
  • The value of cell A4 is greater than or equal to 100

The preceding conditions have been tested by using the following functions (in the given sequence):

Column C shows the outputs obtained by each formula of column B. The row numbers are displayed under the label “Sr. No,” which stands for serial number.

Consider each column and row of the table as the respective column and row of an Excel worksheet.

Sr. No A B C
1 DATA FORMULAS APPLIED RESULTS
2 50 =OR(A2 75,A4>=100) TRUE
3 25 =AND(A2 75,A4>=100) FALSE
4 99 =IF(OR(A2 75,A4>=100),”Data Error”,”Data Correct”) Data Error
5 =IF(AND(A2 75,A4>=100),”Data Error”,”Data Correct”) Data Correct

The conditions tested in column B and their outcomes are listed as follows:

  • A2 75: It evaluates to true because the value of cell A3 (25) is not equal to 75.
  • A4>=100: It evaluates to false as the value of cell A4 (99) is neither greater than nor equal to 100.

The rows of column B are explained as follows:

Row 2: In this row, the three preceding conditions are tested (in cell B2) using the OR excel function. Since one of the three conditions is true, the final output of the OR function (in cell C2) is “true.”

Row 3: In this row, the three preceding conditions are tested (in cell B3) using the AND function. Since two out of three conditions are false, the final output of the AND function (in cell C3) is “false.”

Row 4: In this row, the given conditions are evaluated (in cell B4) using the nested OR function. Since the output of the OR function is “true” (as explained for row 2), the IF function considers that the logical test (condition) has been met. Consequently, the IF function returns the string defined as the “value_if_true” argument, which is “data error” (in cell C4).

Row 5: In this row, the three stated conditions are evaluated (in cell B5) using the nested AND function. The AND function returns the output “false” (as explained for row 3). So, the IF function realizes that the logical test has not been met. As a result, the IF function returns the string “data correct” (in cell C5), which is the “value_if_false” argument.

Note 1: The AND function returns “true” if all the tested conditions evaluate to true. It returns “false” if any of the conditions evaluate to false. Like the OR function, the AND function is also a logical function of Excel.

Note 2: In nesting functions, one function is placed inside another function. The function that is inside is known as a nested function. Excel calculates the nested function first, followed by the outer function. The output of the nested function is used as an argument of the outer function.

Frequently Asked Questions

Yes, Excel does have an OR function. The OR function is available in all versions of Excel. However, there are certain limitations related to the number of conditions that can be tested with the OR function.

Multiple conditions can be tested simultaneously by using the OR function of Excel. It is a logical function of Excel, which returns either of the two Boolean values (true and false) as the outcome. The OR function returns “true” if any or all conditions are true. It returns “false” if all conditions are false.

Note: For the meaning of condition and the number of conditions that can be tested, refer to the introduction and syntax discussed in this article.

The steps to use the OR function with the conditional formatting feature are listed as follows:

a. Select the range on which conditional formatting needs to be applied.
b. From the Home tab, click the “conditional formatting” drop-down from the “styles” group. Select “new rule.”
c. The “new formatting rule” window opens. Choose the option “use a formula to determine which cells to format” under “select a rule type.”
d. Under “format values where this formula is true,” enter the OR formula. For instance, in the range A2:A10, if the numbers greater than 30 or equal to 25 need to be formatted, enter the formula “=OR(A2>30,A2=25)” (without the beginning and ending double quotation marks).
e. Click “format” and select a color from the “fill” tab. Click “Ok” to proceed.
f. Click “Ok” again in the “new formatting rule” window.

The cells of the selected range, for which either of the two conditions (A2>30,A2=25) is true, are colored. The cells, for which both conditions are false, are not colored.

Note 1: When a conditional formatting rule is applied using the OR function, every cell is checked for multiple conditions entered in step “d.” Each cell evaluates to either “true” or “false” and accordingly, formatting is applied. No cell can evaluate to both “true” and “false” at the same time.

Remember that with the OR function, a cell evaluates to “true” if any of the conditions is true. A cell evaluates to “false” if all conditions are false.

Note 2: One can enter more than two conditions in step “d.” Ensure that each condition is separated with commas, as shown by the syntax of the OR function.

To use the OR function with the IF function, insert the former (containing the conditions) within the latter. The text string of each condition must be enclosed within double quotation marks.

For instance, the ranges A2:A11 and B2:B11 contain the names of flowers and trees respectively. The formula “=IF(OR(A2=”rose”,B2=”maple”),”Yes”,”No”)” returns the following outcomes:

a. Yes, if either the first condition (A2=”rose”) or the second condition (B2=”maple”) is true.
b. No, if both conditions are false.

Hence, by combining the OR and IF functions, one can evaluate multiple conditions simultaneously and obtain customized responses for each row. These responses depend on the fulfillment or non-fulfillment of the stated conditions.

Note: Enter the IF and OR formula in Excel by excluding the beginning and ending double quotation marks. Press the “Enter” key after entering the given formula. Drag the formula if the outputs for the entire range are required.

Recommended Articles

This has been a guide to the OR function of Excel. Here we discuss how to use the OR formula in excel along step by step examples. You may also look at these useful functions in Excel–

Источник

Adblock
detector

OR returns either TRUE or FALSE. For example, to test A1 for either “x” or “y”, use =OR(A1=”x”,A1=”y”). The OR function can be used as the logical test inside the IF function to avoid extra nested IFs, and can be combined with the AND function. TRUE if any arguments evaluate TRUE; FALSE if not.

Contents

  • 1 Can you use if and/or together in Excel?
  • 2 How do I do an IF THEN formula in Excel?
  • 3 How does the or function work in Excel?
  • 4 How do you write an IF THEN statement?
  • 5 Can IF statement have 2 conditions?
  • 6 Can you have 3 conditions in an if statement?
  • 7 How do you do true or false in Excel?
  • 8 What are the 3 arguments of the IF function?
  • 9 How do you use the and command in Excel?
  • 10 Can you use if function with text?
  • 11 How do you use if else?
  • 12 How do I leave cell blank if false?
  • 13 What does false mean in Excel?
  • 14 How do you compare two columns in Excel with true or false?
  • 15 What is IF function in Excel explain with example?
  • 16 What are if scenarios in Excel?
  • 17 What is else if statement?
  • 18 Can you do or in Excel?

Can you use if and/or together in Excel?

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)

How do I do an IF THEN formula in Excel?

Use the IF function, one of the logical functions, to return one value if a condition is true and another value if it’s false. For example: =IF(A2>B2,”Over Budget”,”OK”) =IF(A2=B2,B4-A4,””)

How does the or function work in Excel?

Technical Details. The OR function returns TRUE if any of its arguments evaluate to TRUE, and returns FALSE if all of its arguments evaluate to FALSE. One common use for the OR function is to expand the usefulness of other functions that perform logical tests.

How do you write an IF THEN statement?

Another way to define a conditional statement is to say, “If this happens, then that will happen.” The hypothesis is the first, or “if,” part of a conditional statement. The conclusion is the second, or “then,” part of a conditional statement. The conclusion is the result of a hypothesis.

Can IF statement have 2 conditions?

Use two if statements if both if statement conditions could be true at the same time. In this example, both conditions can be true. You can pass and do great at the same time. Use an if/else statement if the two conditions are mutually exclusive meaning if one condition is true the other condition must be false.

Can you have 3 conditions in an if statement?

If you have to write an IF statement with 3 outcomes, then you only need to use one nested IF function. The first IF statement will handle the first outcome, while the second one will return the second and the third possible outcomes. Note: If you have Office 365 installed, then you can also use the new IFS function.

How do you do true or false in Excel?

There are TRUE and FALSE functions in Excel as well. For instance, if you type “=TRUE()” into a cell, it will return the value TRUE. If you type “=FALSE()” it will return FALSE. There is no need to use these functions in standard situations.

What are the 3 arguments of the IF function?

There are 3 parts (arguments) to the IF function:

  • TEST something, such as the value in a cell.
  • Specify what should happen if the test result is TRUE.
  • Specify what should happen if the test result is FALSE.

How do you use the and command in Excel?

The Excel AND function is a logical function used to require more than one condition at the same time. AND returns either TRUE or FALSE. To test if a number in A1 is greater than zero and less than 10, use =AND(A1>0,A1<10).

Can you use if function with text?

If you want to check text values in cells using IF formula in excel (case-sensitive), then you need to create a case-sensitive logical test and then you can use IF function in combination with EXACT function to compare two text values. So if those two text values are exactly the same, then return TRUE.

How do you use if else?

Conditional Statements

  1. Use if to specify a block of code to be executed, if a specified condition is true.
  2. Use else to specify a block of code to be executed, if the same condition is false.
  3. Use else if to specify a new condition to test, if the first condition is false.

How do I leave cell blank if false?

You can’t use the ISBLANK function because it will return FALSE for all cells. The better way here is to use the COUNTBLANK(value) formula. It checks whether the value of a cell is blank.

What does false mean in Excel?

False in excel is a logical function which returns false as an output when used in a blank cell; this function also does not take any arguments similar to the true function in excel; this function is used with the other conditional functions such as the IF function to return a false as a value if the condition is met

How do you compare two columns in Excel with true or false?

Compare Two Columns and Highlight Matches

  1. Select the entire data set.
  2. Click the Home tab.
  3. In the Styles group, click on the ‘Conditional Formatting’ option.
  4. Hover the cursor on the Highlight Cell Rules option.
  5. Click on Duplicate Values.
  6. In the Duplicate Values dialog box, make sure ‘Duplicate’ is selected.

What is IF function in Excel explain with example?

The IF function runs a logical test and returns one value for a TRUE result, and another for a FALSE result. For example, to “pass” scores above 70: =IF(A1>70,”Pass”,”Fail”).The IF function can be combined with logical functions like AND and OR to extend the logical test.

What are if scenarios in Excel?

A Scenario is a set of values that Excel saves and can substitute automatically in cells on a worksheet. You can create and save different groups of values on a worksheet and then switch to any of these new scenarios to view different results.

What is else if statement?

Alternatively referred to as elsif, else if is a conditional statement performed after an if statement that, if true, performs a function.The above example could also be extended by adding as many elsif or else if statements as the program needed. Note. Not all programming languages are the same.

Can you do or in Excel?

The OR function is a logical function to test multiple conditions at the same time. OR returns either TRUE or FALSE. For example, to test A1 for either “x” or “y”, use =OR(A1=”x”,A1=”y”).

To perform complicated and powerful data analysis, you need to test various conditions at a single point in time. The data analysis might require logical tests also within these multiple conditions.

For this, you need to perform Excel if statement with multiple conditions or ranges that include various If functions in a single formula.

Those who use Excel daily are well versed with Excel If statement as it is one of the most-used formula. Here you can check various Excel If or statement, Nested If, AND function, Excel IF statements, and how to use them. We have also provided a VIDEO TUTORIAL for different If Statements.

There are various If statements available in Excel. You have to know which of the Excel If you will work at what condition. Here you can check multiple conditions where you can use Excel If statement.

1) Excel If Statement

Excel-If-functions

If you want to test a condition to get two outcomes then you can use this Excel If statement.

=If(Marks>=40, “Pass”)

2) Nested If Statement

Let’s take an example that met the below-mentioned condition

  • If the score is between 0 to 60, then Grade F
  • If the score is between 61 to 70, then Grade D
  • If the score is between 71 to 80, then Grade C
  • If the score is between 81 to 90, then Grade B
  • If the score is between 91 to 100, then Grade A

Then to test the condition the syntax of the formula becomes,

=If(B5<60, “F”,If(B5<71, “D”, If(B5<81,”C”,If(B5<91,”B”,”A”)

Nested-If-statement

3) Excel If with Logical Test

There are 2 different types of conditions AND and OR. You can use the IF statement in excel between two values in both these conditions to perform the logical test.

AND Function: If you are performing the logical test based on AND function, then excel will give you TRUE as an outcome in every condition else it will return false.

OR Function: If you are using OR condition for the logical test, then excel will give you an outcome as TRUE if any of the situations match else it returns false.

For this, multiple testing is to be done using AND and OR function, you should gain expertise in using either or both of these with IF statement. Here we have used if the function with 3 conditions.

How to apply IF & AND function in Excel

  • To perform this multiple if and statements in excel, we will take the data set for the student’s marks that contain fields such as English and Math’s Marks.
  • The score of the English subject is stored in the D column whereas the Maths score is stored in column E.
  • Let say a student passes the class if his or her score in English is greater than or equal to 20 and he or she scores more than 60 in Maths.
  • To create a report in matters of seconds, if formula combined with AND can suffice.
  • Type =IF( Excel will display the logical hint just below the cell F2. The parameters of this function are logical_test, value_if_true, value_if_false.
  • The first parameter contains the condition to be matched. You can use multiple If and AND conditions combined in this logical test.
  • In the second parameter, type the value that you want Excel to display if the condition is true. Similarly, in the third parameter type the value that will be displayed if your condition is false.Excel-if-statement-multiple-condition-range
  • Apply If & And formula, you will get =IF(AND(D2>=20,E2>=60),”Pass”,”Fail”).

If formula

  • Add Pass/Fail column in the current table.Excel-If-conditions
  • After you have applied this formula, you will find the result in the column.
  • Copy the formula from cell F2 and paste in all other cells from F3 to F13.Excel-If-And-statement

How to use If with Or function in Excel

To use If and Or statement excel, you need to apply a similar formula as you have applied for If & And with the only difference is that if any of the condition is true then it will show you True.

To apply the formula, you have to follow the above process. The formula is =IF((OR(D2>=20, E2>=60)), “Pass”, “Fail”). If the score is equal or greater than 20 for column D or the second score is equal or greater than 60 then the person is the pass.

How to Use If with And & Or function

If you want to test data based on several multiple conditions then you have to apply both And & Or functions at a single point in time. For example,

Situation 1: If column D>=20 and column E>=60

Situation 2: If column D>=15 and column E>=60

If any of the situations met, then the candidate is passed, else failed. The formula is

=IF(OR(AND(D2>=20, E2>=60), AND(D2>=20, E2>=60)), “Pass”, “Fail”).

4) Excel If Statement with other functions

Above we have learned how to use excel if statement multiple conditions range with And/Or functions. Now we will be going to learn Excel If Statement with other excel functions.

  • Excel If with Sum, Average, Min, and Max functions

Let’s take an example where we want to calculate the performance of any student with Poor, Satisfactory, and Good.

If the data set has a predefined structure that will not allow any of the modifications. Then you can add values with this If formula:

=If((A2+B2)>=50, “Good”, If((A2+B2)=>30, “Satisfactory”, “Poor”))

Using the Sum function,

=If(Sum(A2:B2)>=120, “Good”, If(Sum(A2:B2)>=100, “Satisfactory”, “Poor”))

Using the Average function,

=If(Average(A2:B2)>=40, “Good”, If(Average(A2:B2)>=25, “Satisfactory”, “Poor”))

Using Max/Min,

If you want to find out the highest scores, using the Max function. You can also find the lowest scores using the Min function.

=If(C2=Max($C$2:$C$10), “Best result”, “ “)

You can also find the lowest scores using the Min function.

=If(C2=Min($C$2:$C$10), “Worst result”, “ “)

If we combine both these formulas together, then we get

=If(C2=Max($C$2:$C$10), “Best result”, If(C2=Min($C$2:$C$10), “Worst result”, “ “))

You can also call it as nested if functions with other excel functions. To get a result, you can use these if functions with various different functions that are used in excel.

So there are four different ways and types of excel if statements, that you can use according to the situation or condition. Start using it today.

So this is all about Excel If statement multiple conditions ranges, you can also check how to add bullets in excel in our next post.

I hope you found this tutorial useful

You may also like the following Excel tutorials:

  • Multiple If Statements in Excel
  • Excel Logical test
  • How to Compare Two Columns in Excel (using VLOOKUP & IF)
  • Using IF Function with Dates in Excel (Easy Examples)

Понравилась статья? Поделить с друзьями:
  • If com data excel
  • Idioms with the word light
  • If com and no excel
  • Idioms with the word lie
  • Idioms with the word last