string 将单元格内容与 Excel 中的字符串进行比较
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16224783/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Compare cell contents against string in Excel
提问by Pr0no
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.
如果列包含字符串,我需要一个公式来填充B
列,否则。1
A
ENG
0
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?
我试过(在单元格 B1 中),=IF(A1=(TEXT(ENG;FALSE));1;0)
但它#NAME?
在单元格中说。放在ENG
引号之间也无济于事。我的公式应该是什么样的?
回答by Shah
You can use the EXACT
Function for exact string comparisons.
您可以使用EXACT
函数进行精确的字符串比较。
=IF(EXACT(A1, "ENG"), 1, 0)
回答by Duncan Jones
If a case-insensitive comparison is acceptable, just use =
:
如果不区分大小写的比较是可以接受的,只需使用=
:
=IF(A1="ENG",1,0)