Excel: Print Values from Column A not found in Column B in Column C

女生的网名这么多〃 提交于 2019-12-13 02:37:30

问题


I have tried finding this solution on the web but have not had success for this specific problem. In Excel 2010 I have some data in column A where each value may partially contain data in column B.

EX:
Column A might contain "http://google.com/webmasters"
Column B might contain "google.com"
This should give me a match.

I want to print in Column C all values in column A that do not contain any values from column B.

EX:
Column A

http://dir.mydomain.tdl
http://myotherdomain.tdl
http://blog.otherdomain.tdl
http://www.lastdomain.tdl

Column B

mydomain.tdl
lastdomain.tdl

Column C (results required)

http://myotherdomain.tdl
http://blog.otherdomain.tdl

Any help would be greatly appreciated.


回答1:


I think I have the solution using ARRAY formula. Assuming your input AND that columns A-C have titles, or simply, strings are listed starting cells A2 and B2, do the following:

  1. C2: type the formula =IF(OR(NOT(ISERROR(SEARCH(INDIRECT("B2:B"&(COUNTA($B:$B))),$A2)))),"",$A2) but press CTRL+SHIFT+ENTER instead of usual ENTER - this will define an ARRAY formula and will result in {} brackets around it (but do NOT type them manually!).
  2. Autofill formula in C2 until the end of list in column A, e.g. if the last value is in A100, then autofill up to C100 (how long column B does not matter here).
  3. You may then copy & paste obtained results as values and sort out empty strings.

Here you go! The key here - we check every string in column A for having at least one match among array of strings in column B, and return empty string in case at least one match found.

For your convenience sample file is shared: https://www.dropbox.com/s/janf0xxon4z2yh5/DomainsLookup.xlsx




回答2:


Maybe not the must efficient but you could simply use two arrays - one for Column A and one for Column B. Iterate through ColumnA array to see if it exists in ColumnB array (use Array.IndexOf or .contains). If it does you could remove it from the ColumnA array and output the remaining values in Column C as the remainder.



来源:https://stackoverflow.com/questions/14484287/excel-print-values-from-column-a-not-found-in-column-b-in-column-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!