Ask Your Question
0

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

asked 2014-03-13 17:01:46 +0100

Michael Clerx gravatar image

updated 2014-03-14 09:29:50 +0100

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 flag offensive 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

3 Answers

Sort by » oldest newest most voted
1

answered 2014-03-13 21:04:44 +0100

Regina gravatar image

=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 ]

edit flag offensive delete link more

Comments

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

Michael Clerx gravatar imageMichael Clerx ( 2014-03-14 09:23:18 +0100 )edit
0

answered 2014-03-14 09:43:36 +0100

Michael Clerx gravatar image

updated 2014-03-14 09:58:20 +0100

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...

edit flag offensive delete link more
0

answered 2014-03-14 00:52:21 +0100

kumiponi gravatar image

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.

edit flag offensive delete link more

Comments

Extra tip: if you want more powerful tools to manipulate that third column I mentioned, you may want to learn about array functions.

kumiponi gravatar imagekumiponi ( 2014-03-14 01:01:07 +0100 )edit

Thanks! I was hoping to avoid extra columns though, it seemed a simple enough request :-/ For example, conditional formatting can compare columns this way and highlight the mismatches, so I figured counting would be doable to...

Michael Clerx gravatar imageMichael Clerx ( 2014-03-14 09:28:31 +0100 )edit

Question Tools

1 follower

Stats

Asked: 2014-03-13 17:01:46 +0100

Seen: 4,038 times

Last updated: Mar 14 '14