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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 01:53:59  来源:igfitidea点击:

Compare cell contents against string in Excel

stringexcelif-statementcomparison

提问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 Bcolumn with 1if the Acolumn contains the string ENG, or 0otherwise.

如果列包含字符串,我需要一个公式来填充B列,否则。1AENG0

I've tried (in cell B1) =IF(A1=(TEXT(ENG;FALSE));1;0)but then it says #NAME?in the cell. Putting ENGbetween 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 EXACTFunction 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)