结合2个excel公式

时间:2017-02-16 09:37:34

标签: excel excel-formula

在C栏中我有一个文字" xxx已被删除,因为......"或者" xxx已被删除,因为..." 。我有两个公式:

=IF(C3<>"",IF(FIND("has been deleted",C3),LEFT(C3,FIND("has been deleted",C3)-1),"DDDD"),"AAAAAAA")

=IF(C5<>"",IF(FIND("have been deleted",C5),LEFT(C5,FIND("have been deleted",C5)-1),"DDDD"),"AAAAAAA")

我想将两者合并,但它不起作用。这是我尝试过的:

=IF(C4<>"",IF(FIND("have been deleted",C4),LEFT(C4,FIND("have been deleted",C4)-1),IF(FIND("has been deleted",C3),LEFT(C3,FIND("has been deleted",C3)-1),"DDDD")),"AAAAAAA")

=IF(C4<>"",IF(FIND("have been deleted",C4),LEFT(C4,FIND("have been deleted",C4)-1),LEFT(C3,FIND("has been deleted",C3)-1)),"AAAAAAA")

2 个答案:

答案 0 :(得分:2)

公式:

=IF(C1="",  "AAAAAAA",
    IF(  AND( ISERROR( FIND("has been deleted",C1)), 
              ISERROR( FIND("have been deleted",C1))),
        "DDDD",
        LEFT(C1,  IFERROR( FIND("has been deleted",C1), 
                           FIND("have been deleted",C1)) -1))
 )

这是我根据您描述的样本进行的测试:

TEST

请注意公式需要粘贴到D1并拖下来。如图片

答案 1 :(得分:2)

= IF(C1 =&#34;&#34;,&#34; AAAAAA&#34;,IF(OR(ISERROR(找到(&#34;已删除&#34;,C1)),ISERROR (FIND(&#34;已被删除&#34;,C1))),IF(ISNUMBER(&#34;已被删除&#34;,C1)),LEFT(C1,FIND(&#34;已被删除&#34;,C1)-1),IF(ISNUMBER(&#34;已被删除&#34;,C1)),LEFT(C1,FIND(&#34;已被删除&#34; ,C1)-1)&#34; DDDDD&#34;))))

请在D1中输入此公式,它将根据值C1显示结果。 我希望我们能正确理解你的问题。