[英]Excel: if cell 1 contains X or Y or Z, then cell 2 should equal W
As from the title, I need Excel to auto-populate the B row cells based on the corresponding A row cells content.如标题所示,我需要 Excel 根据相应的 A 行单元格内容自动填充 B 行单元格。
So if cell A1
contains X or Y or Z, then cell B1
should equal W, or if A1
contains G or H or J, cell B1
should equal W.因此,如果单元格A1
包含 X 或 Y 或 Z,则单元格B1
应等于 W,或者如果A1
包含 G、H 或 J,则单元格B1
应等于 W。
You can try adding this formula to B1:您可以尝试将此公式添加到 B1:
=IF(OR(A1="X";A1="Y";A1="Z");"W";IF(OR(A1="G";A1="H";A1="J");"W";""))
The first part checks if A1 is either XY or Z. If it's true, it returns "W", if it's false, it will call for another IF statement, that checks if A1 is in GH or J. If it's true, yes, "W" again, if it's not, it'll just put nothing in there.第一部分检查 A1 是 XY 还是 Z。如果是真的,它返回“W”,如果是假的,它会调用另一个 IF 语句,检查 A1 是在 GH 还是 J。如果是真的,是的,再次“W”,如果不是,它只会在其中放置任何内容。
It's possible to simplify it, by using only one IF/OR like this:可以通过只使用一个 IF/OR 来简化它,如下所示:
=IF(OR(A1="X";A1="Y";A1="Z";A1="G";A1="H";A1="J");"W";"")
You might have to replace ;
您可能需要更换;
with ,
depending on your locale settings. ,
具体取决于您的语言环境设置。
如果要将比较值硬编码到公式中,可以像这样收紧。
=IF(OR(A1={"X","Y","Z"}), "W", IF(OR(A1={"G","H","I"}), "K", ""))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.