# How do I count how many text entries in column A match the entry in column B [closed]

I've tried constructs like COUNTIF(A1:A5, EXACT(A1,B1)) but nothing seems to work...

Update 1: I've added an example:

| A | B |

| X | X | --> 1
| X | Y |
| Y | Y | --> 2
| Y | Z |
| Z | Z | --> 3


Here, it should return 3

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by Alex Kemp close date 2016-02-20 07:38:46.488724

Sort by » oldest newest most voted =COUNTIF(A1:A100;B1) For to only count exact matching, check the option "Search criteria = and <> must apply to whole cells" in Tools > Options > Calc > Calculate.

If you have continuous data and column B contains a classification with increasing boundaries, the function FREQUENCY might work as well. [ lower boundary < class <= upper boundary ]

more

I tried this (and again, using your exact syntax) and it simply doesn't work :(

The following seems to work, using array functions. For the cell value, type:

=SUM(A1:A5=B1:B5)


and then hit Ctrl-Shift-Enter to submit it as an array function.

Strangely, adding a space before and after the = sign breaks it...

more I understood that the asker has two columns and wants to find how many rows have matching entries, between those columns. If column A contains, say, potato, turnip, and carrot, and column B contains potato, broccoli, and carrot, then you'd want the value 2.

The normal thing to do in this situation is to create a third column that has a comparison formula on every row, and then count the matches. You first enter =IF(A1=B1;1;0) into C1. Then you select the cells you need in column C and use Edit > Fill > Down. This copies the formula and changes it to suit every row. Then you put something like =SUM(C1:C100) somewhere to count how many rows match. You can hide the third column if you think it looks messy.

Another way to do this, without the extra column, would be to write a macro function. Depending on how versatile you'd want the function to be, it could be quite short or tens of lines long.

more