Close this search box.

How many values are common in 2 lists? [homework]



Here is a formula challenge for you.

How many values are common in 2 lists [homework]

Lets say we have 2 lists of values in A1:A10 & B1:B10

Now, how do you find the number of common values in both lists?

We just want the count, not list of common values it self.

Go ahead and figure out the formula and post your answers here.

Bonus challenges:

  1. Write the formula if 2 lists have non-numeric values (text for example) ?
  2. Write the formula if 2 lists are not of same size (A1:A10 and B1:B15 for example) ?
  3. Write the formula if we have 3 lists (all same size, numeric values) ?

Go ahead and share your answers. I am eager to see what you will come up with.

PS: For some inspiration, check out this forum discussion.

PPS: If you just want to highlight the common values, see this.


Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

Compare two Excel sheets

How to compare two Excel sheets using VLOOKUP? [FREE Template]

You are the boss of ACME Inc. And one day, both of your accounts receivables team members Sara and James come to you with two versions of the customer payment data. How do you compare these two Excel sheets and reconcile the data? In this article, let me explain the step by step process.

78 Responses to “How many values are common in 2 lists? [homework]”

  1. Psuken says:

    I guess this would make it : {=SUM(COUNTIF(A3:A12;"="&B3:B12))}

    It works with both numeric and text values and range B3:B12 can be extended to a third row.

    Note: My excel is in french so I tried to translate functions to english. French formula is  {=SOMME(NB.SI(A3:A12;"="&B3:B12))}

  2. George says:

    If you have your data in Columns A, B and C, put a helper column in, and sum over it:

    It doesn't matter if you compare to all elements in A, B or C, as if it has to be common over all three then it must appear in that list (that's why you only need two statements in your AND() formula) - this can be expanded for as many sets of data as you want, and it doesn't matter about the relative size, as long as you make your helper column as long as column A.  If you were doing this for large sets of data then you'd probably want to replace A with whichever was shortest, but in the example given it doesn't really matter.

     If you wanted to find out if it's common in any two of the three rows it gets a little more complicated, but you still use the same basic idea:


    In this case, you're doing the same basic operation as above, but by replacing the AND() statement with an OR(), and adding in a condition to say "check B against C". This time you have to make your helper column as long as the second shortest of A, B and C.

    When it comes to conditional formatting, you'd use the following:

    To highlight if it's common over all three (in A), juggle about for B and C,
    to highlight if it's common over A and B or A and C.

    Hopefully the explanations make sense, and the formalae work as they look like they do to me,


  3. Grant says:

    I used the following


    The sumproduct avoids having to use CSE to confirm.  

  4. Unai says:

    = SUMPRODUCT( --NOT(ISERROR(MATCH(ListA; ListB; 0))) )
    = SUMPRODUCT( --NOT(ISERROR( MATCH(ListA; ListB; 0) * MATCH(ListA; ListC; 0) )) )

    And the lists can be of different size.

    Congratulations for your excellent blog, Chandoo. I learn (and enjoy) a lot reading it. I must confess, however, that I am in Daniel Ferry's Excel Hero Academy 3, which has inspired this solution to your challenge...


  5. Jaywant Nakti says:

    Condition formating

  6. Tom C says:

    =sum(--not(isna(match(ListA, ListB, 0))))
    I don't think it matters if the lists are different sizes - I used ISNA instead of ISERROR so that it only caught the missing matches, and not any other errors.

  7. Chiquitin says:

    Assuming that first value of List A is in A1, first value of list B is in B1 and first value of list C is in C1, and in order to avoid repeated values in any list, we can use:



    • Chiquitin says:

      Sorry, but in Spanish excel we use semicolon instead comma.


  8. Eric says:

    Grant beat me to it.

  9. Saran says:

    I would use this



  10. Michael says:

    =SUM(COUNTIF($A$1:$A$10,B1:B10)) as an array formula.

  11. Nikhil Tripathi says:

    Hi all,


    Thanks,Nikhil Tripathi

  12. Fred C says:


  13. =if(A=B,1,"")
    Sum of above would give you the total

  14. Shweta Jain says:

    =SUM(COUNTIF($A$1:$A$10,$B$1:$B$10)) with CSE

  15. Kyle McGhee says:

    I will say
    =SUM(IF(Uniques=1,0,1/(Uniques))) (CSE)
    where the named formula "Uniques" is:
    The name is not necessary, just for presentation purposes.
    This method should cover bonus challenges 1 and 3 as well.

  16. Sohail Rizki says:


  17. Jayesh Padhya says:

    =SUM((COUNTIF($D$1:$D$10,C1:C10)>0)*1) as an array formula


  18. Virginia says:


  19. JimmyG says:

    3. =SUM(COUNTIF($A$1:$A$9,B1:B9))+ SUM(COUNTIF($A$1:$A$9,C1:C9))

    as an array 

  20. I tried this and it works:

    =IFERROR(COUNT(MATCH(F6:F15,E6:E15,0)),"") use Ctrl + Shift + Enter.
    It is an array formula.   

  21. shrivallabha says:


  22. Rajan says:

    In this world of emails, have you got bogged down when you require to send same Email to no. of recepients with minor changes...
    It would have taken lot of time and effort to email same matter to different email addresses
    Here comes our solution to this issue.

  23. Detlef says:

    Same formula works for bonus questions 1 and 2.
    Bonus question 3:

  24. kazshak says:

    I tired this one and it worked - entered as ctrl-shift-enter:


  25. Matthew Holbrook says:

    For 2 lists, same size: =SUMPRODUCT(COUNTIF(A1:A11,B1:B11))
    or =SUM(COUNTIF(A2:A11,B2:B11)) (array formula)
    or =SUM(IF(COUNTIF(A1:A11,B1:B11)>0,1,0)) (array formula)

    For 2 lists, different sizes: =SUM(COUNTIF(H2:H11,I2:I16)) (array formula)

    For 3 lists, same size: =SUM(IF(COUNTIF(B16:C25,A16:A25)>1,1,0)) (array formula)

  26. VInay says:

    =SUM(COUNTIF($E$6:$E$17,D6:D17)) (array formula)

  27. rajinikanth says:

    Count of both the list having common values

  28. Manik Nandi says:


    I use below formula:


    Better use sumproduct to  avoid CSE

  29. Waqas says:

    Lot Of Answers
    Now Please tell which one is convenient??? 

  30. Gaurav Bansal says:

    I have used below formula

  31. Amathya says:

    I would use

  32. Manju.N says:

    =IF(COUNTIF($B$3:$B$12,C3)>0,C3&" is common","NA")

  33. nazmul_muneer says:

    It is considered, in the COLUMN A or COLUMN B duplicate value may be typed.
    At first we have find out distinct value in both columns


  34. Kaushik says:

    1) Number of common values in both lists(List A and List B):[List A and List B are headers...data starts from A2 and B2 , respectively.]
    =SUMPRODUCT(COUNTIF(B2:B11,A2:A11))    (ctrl+shift+enter)
    2) Formula if 2 lists have non-numeric values (text for example)
    Same formula works in this case as well
    =SUMPRODUCT(COUNTIF(B2:B11,A2:A11))    (ctrl+shift+enter)
    3) 2 lists are not of same size (A1:A10 and B1:B15 for example)
    Same above formula works but only the reference needs to be changed:
    SUMPRODUCT(COUNTIF(B2:B15,A2:A11))    (ctrl+shift+enter)
    4) Formula if we have 3 lists (all same size, numeric values)
    Along with your list A and List B data , say List C contains: 50,12,69,25,60,30,10,58,21,47 (from C2 to C11):
    Formula would be:
    should return 9

    • Jeanbar says:

      About your 4)
      The answer shouldn't be 9 with the data you provided but 3. The common elements between all tables are 30,50,60.
      On top of this, why do you use SUMPRODUCT when you have only one table e.g. COUNTIF(B2:B11,A2:A11) (cse)? a simple SUM would suffice.

  35. NARENDRA says:

    List A


    List B











































  36. Manoj says:












  37. Vinay Saraf says:

    =SUM(COUNTIF(B1:B10,A1:A10))        CSE ( Ctrl + Shift + Enter)

  38. Jeanbar says:

    My answer, assuming there is no duplicate in either lists:
    1°) Write the formula if 2 lists have non-numeric values (text for example) ?
    2°) Write the formula if 2 lists are not of same size (A1:A10 and B1:B15 for example) ?
    same as above
    3°) Write the formula if we have 3 lists (NOT all same size, NON-numeric values) ?
    I have 3 lists of different sizes LIST_A; LIST_B; LIST_C containing non-numeric values:

    • Jeanbar says:

      In 3°) please read : SUMPRODUCT(COUNTIF(LIST_B,LIST_A),COUNTIF(LIST_C,LIST_A)) (cse)
      (LISt_D replaced by LIST_C)

  39. Oli says:

    Works for alpha, numeric and mixed lists and diferent size lists.


  40. Alok Joshi says:

     entered as an array formula. 

  41. magbo says:

    array formula for two lists (either numeric or text values):

    and for three lists:

    Both formulas should work if lists do not have duplicates

  42. magbo says:

    BTW: easy way to "translate" excel formulas between different language versions is:
    - select a cell with formula
    - open VBA Editor
    - open an Immediate Window
    - type: ?activecell.Formula
    - and press Enter

    And if you have local (not english) version of excel - again 

    - select a cell 
    - open VBA Editor
    - open an Immediate Window
    - type: activecell.Formula = " copy english formula "
    - and press Enter

  43. Akash Khandelwal says:

    I have a single formula which can be used in all these cases :

    1. " =SUMPRODUCT(COUNTIF(A1:A10,B1:B10)) "
                   Works with both Numeric and Text Value.

    2. " =SUMPRODUCT(COUNTIF(A1:A10,B1:B15)) "
                    Just a version of previous formula with changed range.

    3. "=SUMPRODUCT(COUNTIF(A1:A10,C1:C10),COUNTIF(B1:B10,C1:C10))"
                    Extended version of the First Formula, does well with any no. of columns and range.


    Akash Khandelwal 

  44. [...] Re: is this a match ? Hi Coincidently there has been a posting with a similar question at chandoo.org. Check it out. How many values are common in 2 lists? [homework] | Chandoo.org - Learn Microsoft Excel Online [...]

  45. Pablo says:

    This formula array worked, but I don't really know why the division by 2. Maybe it's a case for some Forensics?


  46. Yasmeen says:

    Simplest Way is select the 2 column of list a and list b go to conditional formatting and use duplicate values it will highlight u duplicate values which is in both the columns .."no formula required"....

  47. Amritansh says:

    For three list, array formula

  48. Rajesh Kumar says:

    I have to use conditional formatting.
    step1:I have to select total data wher we want change colour.
    step2:then i have to go in conditional formating & select new rule .
    step3: select Use a formuleto determine which cells to formate.
    step4:Type formule =countif(select unique number column,first cell of selected  data)=1
    step5: fill format as you like

  49. Raj Kumar Kothari says:

    This should work  !!
    =SUM(- -ISNUMBER(1/COUNTIF(B1:B10,A1:A10)))
    Control Shift Enter (CSE)

  50. Joe Farrell says:


    Did this array formula in Libre Office Calc. (Uses semicolons as variable separators.)

  51. teatourist says:

    Place the following in a helper column (E) after the three lists are in columns B,C&D:


    Then just do a COUNT of column E

  52. Brij Arora says:


    With CSE

  53. MAHESH C BHATT says:

    Apply this array formula...

  54. Daniel says:


  55. rahul saha says:

    =SUM(IF(COUNTIF($K$45:$K$49,J45:J49)>0,1,0)) with array passing

  56. Nishant says:


  57. kaushik says:

    {} -> Denotes array formula

  58. adivyom says:

    I created a parallel column C, applied the following formula in C1 and dragged it till C10:


    Sum of '1s' in C1:C10 is the no. of values that are common between A1:A10 and B1:B10.

  59. PINOY-exceler says:

    This works with lists of varying sizes too.


  60. Corne says:

    This works for varying sizes and also only counts unique occurrences:


  61. Yves S says:

    works with different list sizes.


    Criteria range must be same in both arguments. I tested permuting A, B, C. If criteria range is different it won't work.

  62. cnestg8r says:

    This allows numeric/text mixed of different lengths and yields the innerjoin count:


  63. RAJIV SIROHI says:


  64. Anonymous Coward says:


  65. MattS says:


Leave a Reply