组合单元格,除非单元格包含特定文本



我有一个Excel电子表格,其中有7个单元格(在一列中(,其中包含数据,这些单元格是C13到C19我有一个公式,它将这些单元格中的所有数据组合在一起,并将其放入一个单元格中,这个公式是=C13&"amp;C14&"amp;C15&"amp;C16&"amp;C17&"amp;C18&"amp;C19并且工作良好。然而,我是否可以更改此公式以错过任何包含文本"的单元格;没有其他碳水化合物";?

您可以在Excel 2019中使用:

=TEXTJOIN(", ",,IF(C13:C19<>"Nothing else carby",C13:C19,""))

如果";没有其他碳水化合物";可以是单元格值内的子字符串,请尝试:

=TEXTJOIN(", ",,IF(ISNUMBER(FIND("Nothing else carby",C13:C19)),"",C13:C19))

通过CtrlShift输入

公式不应该那么长,正如您所看到的:

=TEXTJOIN(",",TRUE,IF(C13:C19="Nothing","", C13:C19))

(出于可读性的原因,我只是使用了"Nothing"而不是整个单词。(

参数说明:

"," : delimiter: between every cell content, a comma is added.
TRUE : treatment of blank cells (don't put them).
IF (...) : In case cell content is "Nothing", put an empty string. 
In combination with the previous parameter,
just one comma will be put in the result:
"a,b,c,e,f,g" and not "a,b,c,,e,f,g" (see result).

使用数据:

a
b
c
Nothing
e
f
g

结果:

a,b,c,e,f,g

最新更新