检查一个单元格上的多个值并复制一个

时间:2019-03-18 11:52:13

标签: excel excel-formula

我有一个Excell,其中的行之一如下所示:

  

09001 | 09003 | 09017 | 173018 | 8199

     

09001 | 81009 | 173005 | 6709 | 15005

现在,我需要一个单元格的公式,该公式将检查我是否具有某些特定值(例如09003和173005)并将其复制到实际的单元格中。

我寻找的值不会重复,它只是单元格中的一个,应该会更容易,但是我没有幸运地尝试...

以上示例预期的结果:

  

| 09003 |

     

| 173007 |

2 个答案:

答案 0 :(得分:1)

这是我的答案:

9003的公式:

=IFERROR(IF(FIND($B$1,A2)>0,B1,0),"-")

173007的公式:

=IFERROR(IF(FIND($C$1,A2)>0,C1,0),"-")

结果结构:

enter image description here

一个单元格中两个数字的公式:

=IFERROR(IF(FIND("9003",A1)>0,"9003",0),"-") & " " & IFERROR(IF(FIND("173007",A1)>0,"173007",0),"-")

结果:

enter image description here

答案 1 :(得分:1)

例如,可以使用以下Excel函数提取“ 09003”:

说B3是包含源字符串的单元格:

09001 | 09003 | 09017 | 173018 | 8199  

然后:

//                      find start of target string
B4 contains formula 1 [ =LEFT(FIND("09003",B3)) ] // "09003" could also be passed as a cell reference
//                      find end of target string
C4 contains formula 2 [ =RIGHT(FIND("|", B3, B4)) ]
//                      extract string using endpoints
D4 contains result    [ =MID(B3, B4, (B4-C4)+1) ] 

enter image description here