简体   繁体   English

如何根据短语中的一个单词制作 IF 语句以返回另一个单元格的值

[英]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:一些解释:

  1. FIND("FOOD",L7) either finds the word "FOOD" (in capitals) and gives a number, or it yields an error. FIND("FOOD",L7)要么找到单词“FOOD”(大写)并给出一个数字,要么产生错误。
  2. 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.

相关问题 如何根据特定单元格中是否存在单词将一个单元格的值替换为另一个单元格的值 - How to replace the value of one cell with another based on whether a word exists in a specific cell 如何编写if语句代码来比较一张表中两个单元格的值与另一张表中的另一个单元格 - how to write an if statement code to compare two cell's value in one sheet to another cell in another sheet 根据另一个单元格中的月份返回一个单元格值 - Return one cell value based on month in another cell 如何根据另一个单元格值定义一个单元格中公式返回的底值? - How to define a bottom value for a formula's return in a cell based in another cell value? 根据另一个单元格值返回一个单元格值 - Return a cell value based on another cell value 从一个单元格返回另一个单元格的值 - Return value from one cell based off another 如何根据单元格值将行内的范围从一个 Excel 工作表复制到另一个 - How to copy a range within a row from one excel sheet to another based on a cell value Google表格:用于根据另一个单元格的值修改一个单元格的值的case语句或ifelse公式? - Google sheets: Case statement or ifelse formula to modify a cell's value based on the value of another cell? 如何在Excel中将一个单元格的值作为另一个单元格的位置 - How to make the value of one Cell as a position of another Cell in Excel 根据单元格内一个段落中的单个单词,将整行从一张纸复制到另一张纸 - Copy an entire row from one sheet to another based upon a single word, within a paragraph, inside a cell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM