简体   繁体   中英

Compare two Excel columns A&B and add in one cell the data of a third column C of the entries not present in A

I have three columns, two of them are a list of countries. The third column is a list of numbers corresponding to the countries in column A. The formula should compare column A and C and add in a single cell the numbers of the countries not present in list C when compared to A. I want the output to be only one cell, not a list. I've tried with Index & Match and with a Sumproduct and Sumif but I haven't been able to make it work, maybe my syntax was bad. Thanks!

A               B       C         Output  
Austria         1000    Belgium   6000  
Belgium         2000    Spain   
Spain           3000    Portugal  
Portugal        4000  
United Kingdom  5000

As said in the comment:

{=SUM(B1:B10)-SUM(SUMIF(A1:A10,TRANSPOSE(C1:C10),B1:B10))}

will do the job...

being able to run tests, it works even without TRANSPOSE :

{=SUM(B1:B10)-SUM(SUMIF(A1:A10,C1:C10,B1:B10))}

or without sumif: (will be slow / uses lots of resources)

{=SUM(B1:B10)-SUM((A1:A10=TRANSPOSE(C1:C10))*B1:B10)}

Looking for a way without the '-' :
It is hard to exclude something, because you would need an AND or something like that which is only working column or row-wise (and that doesn't exist)... so it is easier to collect every match and then simply subtract it from the unfiltered list... but if you really want to do it that way:

{=SUM(IF(ISERROR(MATCH(A1:A10,C1:C10,0)),B1:B10))}
=SUMPRODUCT(ISERROR(MATCH(A1:A10,C1:C10,0))*1,B1:B10)

Still, it doesn't look very pretty to me while the last one avoids the CSE...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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