Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 250
Pr0no Avatar asked Apr 25 '13 21:04

Pr0no


People also ask

How do I compare cell contents in Excel?

Start a formula with =IF( and enter the two cell locations, separated by an equal sign. Add a comma and enter the text, in quotes, to display if the cells match. Add another comma and then the text, in quotes, for a non-match. For example, the formula could read =IF(A1=B1,"Match","No Match") to compare cells A1 and B1.


2 Answers

You can use the EXACT Function for exact string comparisons.

=IF(EXACT(A1, "ENG"), 1, 0)
like image 93
Shah Avatar answered Oct 21 '22 10:10

Shah


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

=IF(A1="ENG",1,0)
like image 43
Duncan Jones Avatar answered Oct 21 '22 10:10

Duncan Jones