简体   繁体   English

根据字符串部分删除单元格中的值

[英]Remove values in a cell based on a string part

I have a column in Excel that contains a series of comma delimited values.我在 Excel 中有一个包含一系列逗号分隔值的列。 The number of values in each row is different and the values I'm searching for can be in different positions within the cell.每行中的值数量不同,我正在搜索的值可能位于单元格内的不同位置。 I would like to remove some of those values based on based on a string part.我想根据字符串部分删除其中一些值。

Example cell:示例单元格:

2006CE3, 2007CE3, 2012CE1, 2012CE3, 2013CE1, 2013CE3, 2014CE2, 2015CE3, 2016CE2, 2019FA, 2020SP

Specifically, remove all values containing "CE".具体来说,删除所有包含“CE”的值。 In the example above, I would like to remove 2006CE3, 2007CE3, 2012CE1, 2012CE3, 2013CE1, 2013CE3, 2014CE2, 2015CE3, 2016CE2, and leave 2019FA, 2020SP在上面的例子中,我想删除2006CE3, 2007CE3, 2012CE1, 2012CE3, 2013CE1, 2013CE3, 2014CE2, 2015CE3, 2016CE2,并留下2019FA, 2020SP

To do this with a formula one will need TEXTJOIN:要使用公式执行此操作,您需要 TEXTJOIN:

=TEXTJOIN(", ",TRUE,IF(ISNUMBER(SEARCH("CE",FILTERXML("<z><y>"&SUBSTITUTE(A1,",","</y><y>")&"</y></z>","//y"))),"",TRIM(FILTERXML("<z><y>"&SUBSTITUTE(A1,",","</y><y>")&"</y></z>","//y"))))

在此处输入图片说明

Please try this formula solution of which using TEXTJOIN function available for Office 365请尝试使用可用于 Office 365 的 TEXTJOIN 函数的此公式解决方案

In B2 , enter formula :B2 ,输入公式:

=TEXTJOIN(", ",1,INDEX(FILTERXML("<a><b>"&SUBSTITUTE(A2,", ","</b><b>")&"</b></a>","//b[not(contains(.,'CE'))]"),0))

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM