Pr0no
Pr0no

Reputation: 4099

Compare cell contents against string in Excel

Consider the following:

    A   B
1  ENG  1
2  ENG  1
3  FRA  0
4  FOO  0

I need a formula to populate the B column with 1 if the A column contains the string ENG, or 0 otherwise.

I've tried (in cell B1) =IF(A1=(TEXT(ENG;FALSE));1;0) but then it says #NAME? in the cell. Putting ENG between quotation marks doesn't help either. What should my formula be like?

Upvotes: 20

Views: 144549

Answers (2)

Shah
Shah

Reputation: 701

You can use the EXACT Function for exact string comparisons.

=IF(EXACT(A1, "ENG"), 1, 0)

Upvotes: 30

Duncan Jones
Duncan Jones

Reputation: 69329

If a case-insensitive comparison is acceptable, just use =:

=IF(A1="ENG",1,0)

Upvotes: 12

Related Questions