[英]how to make IF statement based on one word within a phrase to return another cell's value
I have this formula:我有这个公式:
=IF(OR(L7="FOOD",L7="GROCERIES"),K7,0)
It only works if for example "FOOD" is the only content.它仅在例如“FOOD”是唯一内容时才有效。 Tonight's Food returns false.
Tonight's Food 返回 false。 I need it to return true regardless of other words.
不管其他词如何,我都需要它返回 true 。
What about this:那这个呢:
=IF(OR(NOT(ISERROR(FIND("FOOD",L7))),NOT(ISERROR(FIND("GROCERIES",L7)))),K7,0)
Some explanation:一些解释:
FIND("FOOD",L7)
either finds the word "FOOD" (in capitals) and gives a number, or it yields an error. FIND("FOOD",L7)
要么找到单词“FOOD”(大写)并给出一个数字,要么产生错误。ISERROR()
checks for an error or not. ISERROR()
检查是否有错误。I would always put the criteria in an extra list - in the screenshot below I named that list 'keywords'我总是将标准放在一个额外的列表中——在下面的屏幕截图中,我将该列表命名为“关键字”
Then you can use this formula - if you have Excel 365 (it spills down) =BYROW(A2:A4,LAMBDA(d,SUM(--ISNUMBER(FIND(keywords,d)))))
然后你可以使用这个公式 - 如果你有 Excel 365 (它溢出)
=BYROW(A2:A4,LAMBDA(d,SUM(--ISNUMBER(FIND(keywords,d)))))
Or if you don't have Excel 365 - then you have to drag down =SUM(--ISNUMBER(FIND(keywords,A2)))
或者,如果您没有 Excel 365 - 那么您必须向下拖动
=SUM(--ISNUMBER(FIND(keywords,A2)))
You will then use this base formula in your IF
-statement like this:然后,您将在
IF
语句中使用此基本公式,如下所示:
=IF(SUM(--ISNUMBER(SEARCH(keywords,L7))),K7,0)
FIND
is case-sensitive, SEARCH
would find "Food" as well. FIND
区分大小写, SEARCH
也会找到“Food”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.