Using logical functions in Excel: AND, OR, XOR and NOT

The tutorial explains the essence of Excel logical functions AND, OR, XOR and NOT and provides formula examples that demonstrate their common and inventive uses.

Last week we tapped into the insight of Excel logical operators that are used to compare data in different cells. Today, you will see how to extend the use of logical operators and construct more elaborate tests to perform more complex calculations. Excel logical functions such as AND, OR, XOR and NOT will help you in doing this.

Excel logical functions - overview

Microsoft Excel provides 4 logical functions to work with the logical values. The functions are AND, OR, XOR and NOT. You use these functions when you want to carry out more than one comparison in your formula or test multiple conditions instead of just one. As well as logical operators, Excel logical functions return either TRUE or FALSE when their arguments are evaluated.

The following table provides a short summary of what each logical function does to help you choose the right formula for a specific task.

Function Description Formula Example Formula Description
AND Returns TRUE if all of the arguments evaluate to TRUE. =AND(A2>=10, B2<5) The formula returns TRUE if a value in cell A2 is greater than or equal to 10, and a value in B2 is less than 5, FALSE otherwise.
OR Returns TRUE if any argument evaluates to TRUE. =OR(A2>=10, B2<5) The formula returns TRUE if A2 is greater than or equal to 10 or B2 is less than 5, or both conditions are met. If neither of the conditions it met, the formula returns FALSE.
XOR Returns a logical Exclusive Or of all arguments. =XOR(A2>=10, B2<5) The formula returns TRUE if either A2 is greater than or equal to 10 or B2 is less than 5. If neither of the conditions is met or both conditions are met, the formula returns FALSE.
NOT Returns the reversed logical value of its argument. I.e. If the argument is FALSE, then TRUE is returned and vice versa. =NOT(A2>=10) The formula returns FALSE if a value in cell A1 is greater than or equal to 10; TRUE otherwise.

In additions to the four logical functions outlined above, Microsoft Excel provides 3 "conditional" functions - IF, IFERROR and IFNA.

Excel logical functions - facts and figures

  1. In arguments of the logical functions, you can use cell references, numeric and text values, Boolean values, comparison operators, and other Excel functions. However, all arguments must evaluate to the Boolean values of TRUE or FALSE, or references or arrays containing logical values.
  2. If an argument of a logical function contains any empty cells, such values are ignored. If all of the arguments are empty cells, the formula returns #VALUE! error.
  3. If an argument of a logical function contains numbers, then zero evaluates to FALSE, and all other numbers including negative numbers evaluate to TRUE. For example, if cells A1:A5 contain numbers, the formula =AND(A1:A5) will return TRUE if none of the cells contains 0, FALSE otherwise.
  4. A logical function returns the #VALUE! error if none of the arguments evaluate to logical values.
  5. A logical function returns the #NAME? error if you've misspell the function's name or attempted to use the function in an earlier Excel version that does not support it. For example, the XOR function can be used in Excel 2016 and 2013 only.
  6. In Excel 2007 and higher, you can include up to 255 arguments in a logical function, provided that the total length of the formula does not exceed 8,192 characters. In Excel 2003 and lower, you can supply up to 30 arguments and the total length of your formula shall not exceed 1,024 characters.

Using the AND function in Excel

The AND function is the most popular member of the logic functions family. It comes in handy when you have to test several conditions and make sure that all of them are met. Technically, the AND function tests the conditions you specify and returns TRUE if all of the conditions evaluate to TRUE, FALSE otherwise.

The syntax for the Excel AND function is as follows:

AND(logical1, [logical2], …)

Where logical is the condition you want to test that can evaluate to either TRUE or FALSE. The first condition (logical1) is required, subsequent conditions are optional.

And now, let's look at some formula examples that demonstrate how to use the AND functions in Excel formulas.

Formula Description
=AND(A2="Bananas", B2>C2) Returns TRUE if A2 contains "Bananas" and B2 is greater than C2, FALSE otherwise.
=AND(B2>20, B2=C2) Returns TRUE if B2 is greater than 20 and B2 is equal to C2, FALSE otherwise.
=AND(A2="Bananas", B2>=30, B2>C2) Returns TRUE if A2 contains "Bananas", B2 is greater than or equal to 30 and B2 is greater than C2, FALSE otherwise.

Using the AND function in Excel formulas

Excel AND function - common uses

By itself, the Excel AND function is not very exciting and has narrow usefulness. But in combination with other Excel functions, AND can significantly extend the capabilities of your worksheets.

One of the most common uses of the Excel AND function is found in the logical_test argument of the IF function to test several conditions instead of just one. For example, you can nest any of the AND functions above inside the IF function and get a result similar to this:

=IF(AND(A2="Bananas", B2>C2), "Good", "Bad")
An example of the IF formula with a nested AND function

For more IF / AND formula examples, please check out his tutorial: Excel IF function with multiple AND conditions.

An Excel formula for the BETWEEN condition

If you need to create a between formula in Excel that picks all values between the given two values, a common approach is to use the IF function with AND in the logical test.

For example, you have 3 values in columns A, B and C and you want to know if a value in column A falls between B and C values. To make such a formula, all it takes is the IF function with nested AND and a couple of comparison operators:

Formula to check if X is between Y and Z, inclusive:

=IF(AND(A2>=B2,A2<=C2),"Yes", "No")

Formula to check if X is between Y and Z, not inclusive:

=IF(AND(A2>B2, A2<C2),"Yes", "No")
An Excel formula for the BETWEEN condition

As demonstrated in the screenshot above, the formula works perfectly for all data types - numbers, dates and text values. When comparing text values, the formula checks them character-by-character in the alphabetic order. For example, it states that Apples in not between Apricot and Bananas because the second "p" in Apples comes before "r" in Apricot. Please see Using Excel comparison operators with text values for more details.

As you see, the IF /AND formula is simple, fast and almost universal. I say "almost" because it does not cover one scenario. The above formula implies that a value in column B is smaller than in column C, i.e. column B always contains the lower bound value and C - the upper bound value. This is the reason why the formula returns "No" for row 6, where A6 has 12, B6 - 15 and C6 - 3 as well as for row 8 where A8 is 24-Nov, B8 is 26-Dec and C8 is 21-Oct.

But what if you want your between formula to work correctly regardless of where the lower-bound and upper-bound values reside? In this case, use the Excel MEDIAN function that returns the median of the given numbers (i.e. the number in the middle of a set of numbers).

So, if you replace AND in the logical test of the IF function with MEDIAN, the formula will go like:

=IF(A2=MEDIAN(A2:C2),"Yes","No")

And you will get the following results:
Using IF with the MEDIAN function to find out all values between the given two values

As you see, the MEDIAN function works perfectly for numbers and dates, but returns the #NUM! error for text values. Alas, no one is perfect : )

If you want a perfect Between formula that works for text values as well as for numbers and dates, then you will have to construct a more complex logical text using the AND / OR functions, like this:

=IF(OR(AND(A2>B2, A2<C2), AND(A2<B2, A2>C2)), "Yes", "No")
An Excel Between formula that works for text values as well as for numbers and dates

Using the OR function in Excel

As well as AND, the Excel OR function is a basic logical function that is used to compare two values or statements. The difference is that the OR function returns TRUE if at least one if the arguments evaluates to TRUE, and returns FALSE if all arguments are FALSE. The OR function is available in all versions of Excel 2016 - 2000.

The syntax of the Excel OR function is very similar to AND:

OR(logical1, [logical2], …)

Where logical is something you want to test that can be either TRUE or FALSE. The first logical is required, additional conditions (up to 255 in modern Excel versions) are optional.

And now, let's write down a few formulas for you to get a feel how the OR function in Excel works.

Formula Description
=OR(A2="Bananas", A2="Oranges") Returns TRUE if A2 contains "Bananas" or "Oranges", FALSE otherwise.
=OR(B2>=40, C2>=20) Returns TRUE if B2 is greater than or equal to 40 or C2 is greater than or equal to 20, FALSE otherwise.
=OR(B2=" ", C2="") Returns TRUE if either B2 or C2 is blank or both, FALSE otherwise.

Using the OR function in Excel

As well as Excel AND function, OR is widely used to expand the usefulness of other Excel functions that perform logical tests, e.g. the IF function. Here are just a couple of examples:

IF function with nested OR

=IF(OR(B2>30, C2>20), "Good", "Bad")

The formula returns "Good" if a number in cell B3 is greater than 30 or the number in C2 is greater than 20, "Bad" otherwise.

Excel AND / OR functions in one formula

Naturally, nothing prevents you from using both functions, AND & OR, in a single formula if your business logic requires this. There can be infinite variations of such formulas that boil down to the following basic patterns:

=AND(OR(Cond1, Cond2), Cond3)

=AND(OR(Cond1, Cond2), OR(Cond3, Cond4)

=OR(AND(Cond1, Cond2), Cond3)

=OR(AND(Cond1,Cond2), AND(Cond3,Cond4))

For example, if you wanted to know what consignments of bananas and oranges are sold out, i.e. "In stock" number (column B) is equal to the "Sold" number (column C), the following OR/AND formula could quickly show this to you:

=OR(AND(A2="bananas", B2=C2), AND(A2="oranges", B2=C2))
The AND/OR formula to test multiple conditions

OR function in Excel conditional formatting

=OR($B2="", $C2="")

The rule with the above OR formula highlights rows that contain an empty cell either in column B or C, or in both.
Using the OR function in Excel conditional formatting

For more information about conditional formatting formulas, please see the following articles:

Using the XOR function in Excel

In Excel 2013, Microsoft introduced the XOR function, which is a logical Exclusive OR function. This term is definitely familiar to those of you who have some knowledge of any programming language or computer science in general. For those who don't, the concept of 'Exclusive Or' may be a bit difficult to grasp at first, but hopefully the below explanation illustrated with formula examples will help.

The syntax of the XOR function is identical to OR's :

XOR(logical1, [logical2],…)

The first logical statement (Logical 1) is required, additional logical values are optional. You can test up to 254 conditions in one formula, and these can be logical values, arrays, or references that evaluate to either TRUE or FALSE.

In the simplest version, an XOR formula contains just 2 logical statements and returns:

  • TRUE if either argument evaluates to TRUE.
  • FALSE if both arguments are TRUE or neither is TRUE.

This might be easier to understand from the formula examples:

Formula Result Description
=XOR(1>0, 2<1) TRUE Returns TRUE because the 1st argument is TRUE and the 2nd argument is FALSE.
=XOR(1<0, 2<1) FALSE Returns FALSE because both arguments are FALSE.
=XOR(1>0, 2>1) FALSE Returns FALSE because both arguments are TRUE.

When more logical statements are added, the XOR function in Excel results in:

  • TRUE if an odd number of the arguments evaluate to TRUE;
  • FALSE if is the total number of TRUE statements is even, or if all statements are FALSE.

The screenshot below illustrates the point:
Excel XOR formula with multiple logical statements

If you are not sure how the Excel XOR function can be applied to a real-life scenario, consider the following example. Suppose you have a table of contestants and their results for the first 2 games. You want to know which of the payers shall play the 3rd game based on the following conditions:

  • Contestants who won Game 1 and Game 2 advance to the next round automatically and don't have to play Game 3.
  • Contestants who lost both first games are knocked out and don't play Game 3 either.
  • Contestants who won either Game 1 or Game 2 shall play Game 3 to determine who goes into the next round and who doesn't.

A simple XOR formula works exactly as we want:

=XOR(B2="Won", C2="Won")
Using the Excel XOR function in a real-life scenario

And if you nest this XOR function into the logical test of the IF formula, you will get even more sensible results:

=IF(XOR(B2="Won", C2="Won"), "Yes", "No")
The IF formula with a nested XOR function

Using the NOT function in Excel

The NOT function is one of the simplest Excel functions in terms of syntax:

NOT(logical)

You use the NOT function in Excel to reverse a value of its argument. In other words, if logical evaluates to FALSE, the NOT function returns TRUE and vice versa. For example, both of the below formulas return FALSE:

=NOT(TRUE)

=NOT(2*2=4)

Why would one want to get such ridiculous results? In some cases, you might be more interested to know when a certain condition isn't met than when it is. For example, when reviewing a list of attire, you may want to exclude some color that does not suit you. I'm not particularly fond of black, so I go ahead with this formula:

=NOT(C2="black")
Using the NOT function in Excel

As usual, in Microsoft Excel there is more than one way to do something, and you can achieve the same result by using the Not equal to operator: =C2<>"black".

If you want to test several conditions in a single formula, you can use NOT in conjunctions with the AND or OR function. For example, if you wanted to exclude black and white colors, the formula would go like:

=NOT(OR(C2="black", C2="white"))

And if you'd rather not have a black coat, while a black jacket or a back fur coat may be considered, you should use NOT in combination with the Excel AND function:

=NOT(AND(C2="black", B2="coat"))

Another common use of the NOT function in Excel is to reverse the behavior of some other function. For instance, you can combine NOT and ISBLANK functions to create the ISNOTBLANK formula that Microsoft Excel lacks.

As you know, the formula =ISBLANK(A2) returns TRUE of if the cell A2 is blank. The NOT function can reverse this result to FALSE: =NOT(ISBLANK(A2))

And then, you can take a step further and create a nested IF statement with the NOT / ISBLANK functions for a real-life task:

=IF(NOT(ISBLANK(C2)), C2*0.15, "No bonus :(")
A nested IF statement with NOT / ISBLANK functions

Translated into plain English, the formula tells Excel to do the following. If the cell C2 is not empty, multiply the number in C2 by 0.15, which gives the 15% bonus to each salesman who has made any extra sales. If C2 is blank, the text "No bonus :(" appears.

In essence, this is how you use the logical functions in Excel. Of course, these examples have only scratched the surface of AND, OR, XOR and NOT capabilities. Knowing the basics, you can now extend your knowledge by tackling your real tasks and writing smart elaborate formulas for your worksheets.

567 comments

  1. I've been trying to figure this out for two days using various resources and I'm stuck. I feel like the solution is easy and I'm just overthinking it at this point.

    Let's say I have a table in Excel with headers and many rows of varying text and numbers, with some cells containing both (random ID numbers generated by an outside source). The table and headers have names for use in other formulas (no trouble there).

    Col_With_Hdr_1
    A Specific Name In This Cell
    Another Specific Name In This Cell

    Col_With_Hdr_8
    (123abc678ruw9257xyz)
    this is literally a blank cell
    (2756imv47zqp115mv2)
    this is literally a blank cell

    Col_With_Hdr_11
    formula result displayed as text goes here
    formula result displayed as text goes here
    this would be blank if formula result is 0 or No

    I can't figure out how to write a formula that shows

    IF Col_With_Hdr_1="A Specific Name in This Cell" then put specific text in Col_With_Hdr_11

    OR

    IF Col_With_Hdr_8 IS NOT BLANK then put same specific text in Col_With_Hdr_11

    I hope this makes sense, and I appreciate any ideas anyone may have. Thank you!

  2. Hi, I need to calculate the tax for the incomes. If the income is 5000 that is tax free. If the income is greater than 5000 and less than 12500 then, it is 12500-5000 and the remaining is taxed 2% and if the income is more than 12500 and less than 100000 then first 5000 is deducted then 12500 is deducted to be taxed 2% and then the remaining is taxed 10% and if the income is more than 100000 then the 87500 is to be taxed at 10% and then the remaining is taxed 20%. Is it possible to bring them in only one function? Thanks for your kind support.

  3. Using excel formulae, find out the following
    1. How many have neither registered nor completed any of the 3 courses?
    2. How many have registered or trained in atleast 2 of the 3 courses?
    3. How many have not been trained in any of the 3 yet?

    R - Registered for training (training not done yet)
    T - Trained
    Blank - Neither

    Name SQL SAS Excel
    Prakash R T
    Rahul R
    Rajiv
    Priya R T
    Amit T

  4. I wrote the following code. The code provides partial result correctly, but not all! I don't know what is the wrong with my code? =IF((Distance/C4)<1, E_saved,(IF((Distance/C4)<2, (E_saved-(1.8*((Distance/C4)-1))),(IF((Distance/C4)<4, (E_saved-(1.8+(3.35*((Distance/C4)-2)))),(IF((Distance/C4)<11,(E_saved-(1.8 +(3.35*2)+(2.375*(Distance/C4)-4))),0)))))))

  5. I need formular for 2 criterias,

    Increase base salary offer (X)
    if GPA is
    >3.5 by 2000
    >3.0 by 1000
    >2.5 by 500

    and additional bonus
    if experiential activity
    >4.5 $3,500
    >4.0 $3,000
    >3.0 $2,500

  6. SL P A = Error
    - P - = P
    SL P - = SL
    - P A = A

  7. hi,
    What formula could i use if i don't want a number to go over 7.5...If a number is lower, is displays the actual number but if it's higher it shows only 7.5
    THank you,

    • HI..

      =IF(H19<7.5,H19,7.5)

  8. How to write a formula for this
    10 - 64 Reading below grade level
    65- 81 On Level
    82 - 100 Reading above grade level

    Thank you so much

    • Hello, Arcita,
      Please try the following formula:

      =IF(A1<=64, "Reading below grade level", IF(A1<=81, "On Level", IF(A1<=100, "Reading above grade level")))

      You can learn more about Excel Nested IF in Excel in this article on our blog.

      Hope you'll find this information helpful.

  9. Hi all
    How can i insert any function in the criteria of countif
    For example i have a marks sheet i want to count that how many student get 80% or more then 80% marks in examination
    One way is i have to calculate the 80% and write in the criteria
    What is another way??

  10. I have A2=28, B2=45 to get a smaller value i applied the formula =IF(A2>B2,A2-B2,A2). So i got an answer has 28.

    My question is if i change a value in A2=50 now i should get a value has B2 in C2 cell.

    So i have entered has =IF(A2>B2,A2-B2,A2)*OR(IF(A2<B2,B2,B2))

    Still it is not working, can someone assist me how to put a formula with a proper condition?

  11. You have eliminated my sleepless night for weeks now.
    Thanks

  12. COMPLETE SUCCESS

    I used the following formulas to test and see if the date format translates to a number, which it did
    =LEFT(MONTH(D13),2)

    Then expanded it to check for output for two months - it worked
    =IF(LEFT(MONTH(D11),2)="5","May",IF(LEFT(MONTH(D11),2)="6","Jun",""))

    FORMULA WHICH WORKED (expanded it to 12 months, put Jan as 01)
    ------------------------------
    =IF(LEFT(MONTH(D10),2)="01","Jan",IF(LEFT(MONTH(D10),2)="2","Feb",IF(LEFT(MONTH(D10),2)="3","Mar",IF(LEFT(MONTH(D10),2)="4","Apr",IF(LEFT(MONTH(D10),2)="5","May",IF(LEFT(MONTH(D10),2)="6","Jun",IF(LEFT(MONTH(D10),2)="7","Jul",IF(LEFT(MONTH(D10),2)="8","Aug",IF(LEFT(MONTH(D10),2)="9","Sep",IF(LEFT(MONTH(D10),2)="10","Oct",IF(LEFT(MONTH(D10),2)="11","Nov",IF(LEFT(MONTH(D10),2)="12","Dec",""))))))))))))

    • Used the LEFT(MONTH(CELL_REF),2) to verify the translation of the date to number, THEN expanded it to the following, it worked.

      =IF(LEFT(MONTH(D10),2)="01","Jan",IF(LEFT(MONTH(D10),2)="2","Feb",IF(LEFT(MONTH(D10),2)="3","Mar",IF(LEFT(MONTH(D10),2)="4","Apr",IF(LEFT(MONTH(D10),2)="5","May",IF(LEFT(MONTH(D10),2)="6","Jun",IF(LEFT(MONTH(D10),2)="7","Jul",IF(LEFT(MONTH(D10),2)="8","Aug",IF(LEFT(MONTH(D10),2)="9","Sep",IF(LEFT(MONTH(D10),2)="10","Oct",IF(LEFT(MONTH(D10),2)="11","Nov",IF(LEFT(MONTH(D10),2)="12","Dec",""))))))))))))

      • Sunny:
        Alright! That's a lot of nested IF's but you figured it out. Congratulations on a good use of the MONTH function.
        Thank you for sharing. I'm sure others will benefit from your work.

  13. SUCCESS:
    I was able to achieve and find the conversion of the date format to a number with "=LEFT(MONTH(D13),2)"

    THEN, I expanded the formula to:
    =IF(LEFT(MONTH(D12),2)="1","Jan", IF(LEFT(MONTH(D12),2)="2","Feb", IF(LEFT(MONTH(D12),2)="3","Mar",IF(LEFT(MONTH(D12),2)="4","Apr",IF(LEFT(MONTH(D12),2)="5","May",IF(LEFT(MONTH(D12),2)="6","Jun",IF(LEFT(MONTH(D12),2)="7","Jul",IF(LEFT(MONTH(D12),2)="8","Aug",IF(LEFT(MONTH(D12),2)="9","Sep",IF(LEFT(MONTH(D12),2)="10","Oct",IF(LEFT(MONTH(D12),2)="11","Nov",IF(LEFT(MONTH(D12),2)="12","Dec",""))))))))))))

    BUT
    The blank cells are coming up with "Jan" where it should be a blank "" as in the formula above.
    Any suggestions or input?

  14. I am trying to find a formula where if a LEFT 2 is 01, 02, 03 etc (for date 01/01/18 style), and it enters:
    - Jan if it is 01 of a 01/01/18 date format
    - Feb if it is 02 of a 02/01/18 format
    I have tried the following, but it did not work:
    =IF(LEFT(D21,2)="01","Jan",IF(LEFT(D21,2)="02","Feb",""))
    Kindly assist.
    Sunny

  15. Hi,
    Please Help.
    For testing some lower percentages requires logic test result in the list.
    READING NOW PREVIOUS RESULT ACTION
    -10% -8%
    -25% -12% REJECT
    10%
    25% POSITIVE

    FOR - VE UP TO 10% IF PREVIOUS TEST IS POSITIVE (ABOVE 0%) RE-TEST
    FOR - VE UP TO 10% IF PREVIOUS TEST IS NEGATIVE (ABOVE 0%) DOSE CHANGE
    FOR + VE UP TO 10% IF PREVIOUS TEST IS NEGATIVE (BELOW 0%) FOR CURING
    FOR + VE UP TO 10% IF PREVIOUS TEST IS POSITIVE(BELOW 0%) NEXT TEST

    READING NOW PREVIOUS RESULT ACTON
    -8.0% 5.0% RE-TEST
    -12.0% -8.0% DOSE CHANGE
    8.0% -12.0% FOR CURING
    12.0% 8.0% NEXT TEST
    22.0% 10.0% IF(A1825%,"POSITIVE,IF(AND(A18=0%,"RE-TEST"),IF(AND(A18>=0%,B18<=0%,"FOR CURING")))
    17.5% 4.0%
    2.0% -8.0%
    -6.0% -12.0%
    8.0% -1.0%
    -5.0% 8.0%

  16. i want to have logical comparision or any suitable formula for folowing condition pls guide.
    if column one value is pipe ,column 2 value is carbon steel,column 3 value is
    2Inch,column 4 value is -40 schedule,column 5 value(heat no) will be "abcd"
    also in same formula column 4 may varry like it may40,80,160 many numbers then my column 5 will be identified value to add in column 5.i.efor 40 sch colm5 value is abcd if column 4 value is 80 then column5 value is efgh,if column 4 value is 160 then column5 value is ijkl.

  17. I need help with an "IF" "AND" formula.

    I am looking for the logic when I have a test score in box B1 and want to create a rule:

    IF B1 > 0.5, but B1 0.6 and smaller than 0.7 make C1 = Level 2
    AND IF B1 > 0.7 make C1 = Level 3
    IF FALSE = Unfit

  18. This might be one of the best excel tutorials I've ever read! Very well written, and the examples really help show how the functions work.

    Thank you!

  19. Hello, I need some help with formula related to day of the week. If day = Tuesday or Thursday, a formula needs to be incremented by 1. I can get it to return True if the day is Tuesday or Thursday and have that in a column.

    I tried the formula below but it increments by 1 no matter what h3 is.
    =IF(h3="FALSE",(1+$k$3-j3),($k$3-j3))

    I also tried this but it also increments by 1 no matter what h3 is.
    =IF(h3="FALSE",($k$3-j3),(1+$k$3-j3))

  20. If have to add the print the the value in C1.
    I need add the student marks for the following condition A means if student Absent in subject.A1=Theory Marks,B1=Practical Marks,C1=Final marks Means A1+B1=C1
    case-1
    A1=5 B1=10 C1=15
    Case-2
    A1=5 B1="A" C1=05
    Case-2
    A1="A" B1=10 C1=10
    Case-2
    A1="A" B1="A" C1=0

    any body please help to write formula for that.
    Kindly give me formula for that

    • Anurag:
      If you can simply put a "0" in A or B when student is absent then the formula is very simple. In C1 just enter =A1+B1.
      If you must enter an "A" in a cell when student is absent then put this formula in C1: =IFERROR(IF(A1="A",(0+B1),IF(B1="A",(0+A1),(A1+B1))),"Student Was Absent for Both Subjects")
      If A1 and B1 both hold "A" the IFERROR returns the message, "Student Was Absent for Both Subjects".
      You can change the cell addresses and the message to suit your needs.

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)