x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 257

# Excel 2010 - Count common elements

Dear Experts,

Can you please have a look at the attached file, it contains small data on Sheet1 and Sheet2, both in A column.

Could you advise which formula could give back a number that how many common elements are on the two sheets in column A? In the example this would be 3, because only the 101,102 and 107 are on both sheets

thanks,
CommonInColumn.xlsx
0
csehz
• 3
• 2
1 Solution

Microsoft MVP ExcelCommented:
Hello,

try

=SUM(--(NOT(ISERROR(MATCH(A2:A7,Sheet1!A2:A5,0)))))

This is an Array formula and needs to be entered with Ctrl-Shift-Enter

Or a non-array formula, confirmed with a simple Enter

=SUMPRODUCT(--(NOT(ISERROR(MATCH(A2:A7,Sheet1!A2:A5,0)))))

cheers, teylyn
0

IT consultantAuthor Commented:
Teylyn thanks very much it works, can I put such array formula also to VBA?

thanks,
0

Microsoft MVP ExcelCommented:
Possibly. But that would be a different question, since this one has been answered.
0

IT consultantAuthor Commented:
Thanks :-)
0

Commented:
Can there be duplicates? For example if A6 became 102 there would still arguably be 3 common elements......but teylyn's formulas would return 4?

regards, barry
0

IT consultantAuthor Commented:
Barry well for me fortunately on the live files the columns sure do not have duplicates. So I even did not think to such scenario, however yes can be a good next question too :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.