Search code examples
excelexcel-formulaexcel-2010excel-2007

Where I am wrong to combine AND() and OR() within Excel formulae?


Where I am wrong to combine AND() and OR() within Excel formulae ?

=If(OR(Sheet1!BC="A",Sheet1!BC="B" ) AND (Sheet1!CI<>"",Sheet1!CA=""),Sheet1!CI,Sheet1!CA)

Whats wrong I am doing in here ? Please help


Solution

  • There are several issues:

    1) AND() is a function that works the same as OR():

    =IF(AND(a1=2, b1=3, c1=6), "true", "false")
    

    2) Here's an example of combining AND() and OR() in a single equation:

    =IF(AND(OR(a1=1, b1=2), OR(a2=9, b2=10)), "true", "false")
    

    That reads If (a1=1 or b1=2) and (a2=9 or b2=10)

    3) You're only referencing column names in your formula, not cell names. If you want to compare the value for a cell, you need to include the row number. So BC needs to be BC# (where # is the correct row), CI needs to be CI#, CA needs to be CA#

    4) What you have after the AND() in your example doesn't make any sense.

    (Sheet1!CI<>"",Sheet1!CA=""),Sheet1!CI,Sheet1!CA)
    

    Did you mean to put an OR() around the first two? What are the second two CI and CA for?

    I tried to rewrite your equation, but it's not clear what you're trying to do.