简体   繁体   English

Excel:如果在另一列中找到匹配项,则删除文本字符串的一部分

[英]Excel: Remove part of text string if a match is found in another column

I have a list of data with the company name and address. 我有一个包含公司名称和地址的数据列表。 However in the address column, the company name is joined with the address. 但是,在地址栏中,公司名称与地址结合在一起。 I want to know if it is possible to compare these 2 columns and remove the company name from the address. 我想知道是否可以比较这两列并从地址中删除公司名称。

See attached pic 见附件图片 在此处输入图片说明

将此粘贴到单元格c2中

IF(ISERROR(SEARCH(A2,B2,1)),B2,RIGHT(B2,LEN(B2)-LEN(A2)))

in column C use: 在C列中使用:

=TRIM(SUBSTITUTE(B2,Right(A2,len(A2)-find(" ",A2)),""))
  • The RIGHT function will strip off the leading number. RIGHT功能将删除开头的数字。

  • The SUBSTITUTE function replaces what is left of A2 that is found in B2 with nothing. SUBSTITUTE函数将B2中剩余的A2内容替换为空。

  • The TRIM function removes the leading space. TRIM功能消除了前导空间。


Update 更新资料

Just to be on the safe side in case there might be more than one space between the "." 为了安全起见,以防在“。”之间存在多个空格。 and the start of the name, or trailing spaces in the name. 以及名称的开头,或名称中的尾部空格。

=TRIM(SUBSTITUTE(B2,TRIM(Right(A2,len(A2)-find(" ",A2))),""))

Added a TRIM function to what is being pulled from column A. 向从列A拉出的内容添加了TRIM函数。

在C2中并填写:

=TRIM(SUBSTITUTE(B2,MID(A2,SEARCH(". ",A2,1)+2,500),""))

这么多的选择!

=RIGHT(B1,LEN(B1)-IFERROR(FIND(A1,B1,1),0))

Another one from my side 我身边的另一个

=MID(B1,(LEN(A1)+2),99)

显示结果的快照

暂无
暂无

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

相关问题 使用Excel进行字符串操作 - 如果有其他部分,如何删除部分字符串? - String manipulation with Excel - how to remove part of a string if another part is there? EXCEL:检查是否在另一列中找到单元格文本 - EXCEL: Check if cell text is found in another column Excel-在另一列中找到匹配项的行中获取列的值 - Excel - Get value of a column in a row where match found in another column Excel:根据另一个单元格(字符串)删除部分单元格(字符串) - Excel: Remove part of cell (String) based on another cell (String) Excel 将一个单元格的文本与另一个单元格匹配并删除匹配的文本 - Excel match text of one cell with another and remove the matching text VBA EXCEL 在列中的文本字符串与不同工作表上的不同列中搜索匹配项。 如果找到匹配项,复制并粘贴 - VBA EXCEL Search for matches in a string of text in a column vs a different column on a different sheet. If match found, Copy & Paste EXCEL VBA:匹配字符串的一部分 - EXCEL VBA: match part of a string 从Excel中的另一个A查找B列中的一部分文本 - To find a part of text in column B from another A in excel 检查文本列A中的字符串,并返回列B中的另一个字符串-Excel - Check for string in text column A, return another string in column B - Excel 如何从另一列的值中删除文本字符串的一部分? - How to delete part of a text string from the values of another column?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM