【问题标题】:How can I ignore blank cells while concatenating in Excel with added text?如何在 Excel 中连接添加文本时忽略空白单元格?
【发布时间】:2019-04-25 14:49:57
【问题描述】:

所以我有一个连接公式,我将两列与文本结合起来。


=CONCATENATE(B3,".",C3,"@company.com")

它会获取我的联系人姓名并生成电子邮件。


示例:

B3:约翰
C3:史密斯

输出:John.Smith@company.com


我的问题是它会将“@company.com”留在带有空白单元格的行中。

我不想那样。请帮忙?????????

【问题讨论】:

    标签: excel email concatenation contacts


    【解决方案1】:

    如果您有 Excel 2016 或更新版本,我建议使用 TEXTJOIN Function 而不是 CONCAT,因为 TEXTJOIN 可以选择忽略空白。

    使用早期版本的 Excel,您可以将自己的版本构建为自定义函数,例如这个:

    Function TxtJoin(delim As String, ignoreEmpty As Boolean, rg As Range) As String
        Dim c As Range
        For Each c In rg
            If Not ignoreEmpty Or Not IsEmpty(c) Then TxtJoin = TxtJoin & delim & c
        Next c
        If TxtJoin <> "" Then TxtJoin = Mid(TxtJoin, Len(delim) + 1)
    End Function
    

    这是我的另一个答案here。

    还有一个类似的问答here。

    【讨论】:

      【解决方案2】:

      建议你使用简单的 If 与使用 cencatenate。我使用 AND 也是因为我认为 b3 和 c3 都需要为空,试试看。 如果只有另一个是空的,它将执行公式

      =IF(AND(B3="",C3=""),"",CONCATENATE(B3,".",C3,"@company.com"))
      

      像这样 enter image description here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-02-17
        • 2018-11-20
        • 1970-01-01
        • 1970-01-01
        • 2016-03-24
        • 1970-01-01
        • 2011-04-19
        • 1970-01-01
        相关资源
        最近更新 更多