• Do I use the OR function, or something else? (2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Do I use the OR function, or something else? (2000)

    Author
    Topic
    #396906

    The short version: How do I tell Excel that if a cell contains one of a group of values, it should perform some sort of operation? I can’t seem to make OR work; am I on the wrong track?

    The long version: If a cell contains a specific value (A, B, C or D), I want Excel to indicate “yes”, otherwise indicate “no”. In quasi Excel-English it would look like this:
    =IF(A1=(“A” or “B” or “C” or “D”), “yes”,”no”)
    which, of course, doesn’t work at all.

    When I try to use Excel language:
    =IF(A1=OR(“A”, “B”, “C”, “D”), “yes”,”no”)
    I get an error. From what I can figure out, it will only tell me “yes” if A1 contains all four letters, but that doesn’t make any sense. My brain hurts.

    How should I write the formula so that it will tell me if cell A1 contains any of those letters.

    Viewing 1 reply thread
    Author
    Replies
    • #747419

      I think you have your OR parameters messed up ..
      If you want this:
      IF(A1=OR(“A”, “B”, “C”, “D”), “yes”,”no”)
      Try this:
      =IF (OR(A1=”A”,A1=”B”,A1=”C”,A1=”D”),”YES”,”NO”)

      kinda cumbersome, but that’s how it works.

      –CAT

      • #747435

        You can also use:

        =IF(ISERROR(FIND(A1,"A,B,C,D")),"No", "yes")

        for case sensitive

        Or for case insensitive:

        =IF(ISERROR(Search(A1,"A,B,C,D")),"No", "yes")

        This is easier to enter, if you have a lot of items to OR

        Steve

        • #747536

          This is another way (which is similar) to your original scheme

          =IF(ISNA(MATCH(A1,{"A","B","C","D"},FALSE)),"No", "yes")

          Steve

        • #747537

          This is another way (which is similar) to your original scheme

          =IF(ISNA(MATCH(A1,{"A","B","C","D"},FALSE)),"No", "yes")

          Steve

      • #747436

        You can also use:

        =IF(ISERROR(FIND(A1,"A,B,C,D")),"No", "yes")

        for case sensitive

        Or for case insensitive:

        =IF(ISERROR(Search(A1,"A,B,C,D")),"No", "yes")

        This is easier to enter, if you have a lot of items to OR

        Steve

    • #747420

      I think you have your OR parameters messed up ..
      If you want this:
      IF(A1=OR(“A”, “B”, “C”, “D”), “yes”,”no”)
      Try this:
      =IF (OR(A1=”A”,A1=”B”,A1=”C”,A1=”D”),”YES”,”NO”)

      kinda cumbersome, but that’s how it works.

      –CAT

    Viewing 1 reply thread
    Reply To: Do I use the OR function, or something else? (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: