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

时间:2021-05-28 07:42:48

标签: excel excel-formula excel-2019

我有一个 Excel 电子表格,其中有 7 个单元格(在一列中),其中包含数据,这些是 C13 到 C19 我有一个公式将这些单元格中的所有数据组合在一起并将其放入一个单元格中,这个公式是 =C13&", "&C14&", "&C15&", "&C16&", "&C17&", " &C18&", "&C19 并且工作正常。但是,我可以更改此公式以遗漏包含文本“Nothing else carby”的任何单元格吗?

2 个答案:

答案 0 :(得分:1)

您可以在 Excel 2019 中使用:

private UserAccount _userAccount;
public UserAccount CurrentUserAccount
{
    get { return _userAccount; }
    set
    {
        if (_userAccount != null)
            _userAccount.PropertyChanged -= OnUserAccountPropertyChanged;
        _userAccount = value;
        if (_userAccount != null)
            _userAccount.PropertyChanged += OnUserAccountPropertyChanged;
        OnPropertyChanged(nameof(CurrentUserAccount));
    }
}

private void OnUserAccountPropertyChanged(object sender, PropertyChangedEventArgs e) =>
    OnPropertyChanged(null);

如果“Nothing else carby”可以是单元格值内的子字符串,请尝试:

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

通过CtrlShift回车

确认

答案 1 :(得分:0)

公式不应那么长,如您所见:

processed = set()
if isinstance(statements, list):
    processed.update(statements)
else:
    processed.add(statements)

(出于可读性原因,我只是使用了“Nothing”而不是整个词。)

参数说明:

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

使用的数据:

"," : 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
相关问题