简体   繁体   English

将单元格值与 If 公式的结果连接起来

[英]concatenate the cell value with result of If formula

I have the formula below which checks cell C6 and if C6="Yes", formula will return "X".我有下面的公式来检查单元格 C6,如果 C6="Yes",则公式将返回 "X"。

IF(C6="Yes","X","") 

I now want this formula to concatenate the value of Cell C5 to string "X" only when the C6="Yes".我现在希望这个公式仅在 C6="Yes" 时将单元格 C5 的值连接到字符串 "X"。 How can I formulate this?我怎样才能制定这个?

Thanks in advance!提前致谢!

像这样,使用&连接:

IF(C6="Yes","X"&C5,"") 

As an addendum to Scott's answer, depending on your purpose you can also use CONCAT or TEXTJOIN .作为 Scott 答案的附录,根据您的目的,您还可以使用CONCATTEXTJOIN For instance:例如:

=IF(C6="Yes",CONCAT("X",C5),"") 

...or... ...或者...

=IF(C6="Yes",TEXTJOIN(" ",TRUE,"X",C5),"") 

If C5 is "example", these would result in "Xexample" and "X example", respectively.如果 C5 是“example”,它们将分别产生“Xexample”和“X example”。 As Plutian mentioned, this is particularly useful if you're going to have more entries.正如 Plutian 所提到的,如果您要拥有更多条目,这将特别有用。 TEXTJOIN is particularly useful if you're trying to make a sentence or concatenate an address separated by commas.如果您尝试创建一个句子或连接由逗号分隔的地址,则TEXTJOIN特别有用。 It can also ignore blank cells, which can be handy.它还可以忽略空白单元格,这很方便。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM