# IF + OR formula

#### amp7394

##### New Member
What would be the correct formula for IF a cell contains text x OR contains text Y, then give me Z value. Right now I have:

=IF(SUM(COUNTIF(A6,{"BSC-NCORP-A","BSC-CORP-A"})),"BSC","CIG")

But I am only getting the CIG value for everything.

### Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

#### Aryatect

##### Active Member
Hi, I think below should work:

#### amp7394

##### New Member
Hi, thank you for your response. I am actually only asking Excel to look for a portion of the cell. The entire A5 cell says:
 BSC-NCORP-A|PLT-NA-NA|CIG-NA-NA|GLD-NCORP-L So, IF A5 contains BSC-NCORP-A or BSC-CORP-A, then BSC, if not CIG. How would I edit the formula so that its only asking to look portion of text in the cell?

<tbody>
</tbody>

#### FormR

##### MrExcel MVP
Hi, see below additions in red to you original formula.

=IF(SUM(COUNTIF(A6,"*"&{"BSC-NCORP-A","BSC-CORP-A"}&"*")),"BSC","CIG")

Last edited:

1,089,449
Messages
5,408,283
Members
403,195
Latest member
biafrapl