'Excel Formula to display text based on value of two cells

Im looking for a way to display text of a cell based on the below two conditions :

  1. If Cell C20 contains certain words like "ghan", "ERC", "VSL" AND cell D22 is <> "-" then cell i22 should display the content of cell C20.

  2. If cell C20 does not contain any of these words regardless whether D22 is ="-" or contains a number it should remain as "-"

Screenshot attached

Here's what i have tried so far :

1) =IF(AND(ISNUMBER(Aug!I555),ISNUMBER(SEARCH("ERC",Aug!B555))),Aug!B555,"-")
2) =IF(ISNUMBER(Aug!I596),Aug!B596,IF(ISNUMBER(SEARCH("*ERC*",Aug!B596)),Aug!B596,"-"))

This is what im using for now as a temporary solution

3) =IF(D22<>"-",IF(ISNUMBER(SEARCH("ghantoot",C20)),C20,IF(ISNUMBER(SEARCH("sand",C20)),C20,IF(ISNUMBER(SEARCH("vsl",C20)),C20,IF(ISNUMBER(SEARCH("wet",C20)),C20,"-")))))

enter image description here



Solution 1:[1]

In I22:

    =IF(ISNUMBER(D22),
        IF(OR(ISNUMBER(SEARCH("ghan",C20)),
              ISNUMBER(SEARCH("ERC",C20)),
              ISNUMBER(SEARCH("VSL",C20))),
           C20,
           "-"),
        IF(D22="-","-","d22 not number & not -"))

I don't think you stated what happens with all branches of the logic, so I have put placeholder text there for you to fill in yourself. This is:

  • "d22 not number & not -"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1