COUNT column matching criteria

JamesWayne

New Member
Joined
Sep 6, 2017
Messages
15
Hi All, I've been trying to work out a formula that will count a column if the criteria is matched and I've using SUMPRODUCT, COUNTIF functions without much success.

What I'm after is if range A1:A3 matches cell D1 then COUNTA column B is basically what I need to work. I don't want column A to be counted, column A is just the criteria to work out what in column B to count.

Answer below should be 2 (no sum, just count), thank you.

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Car 1[/TD]
[TD]11[/TD]
[TD][/TD]
[TD]Car1[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Car 2[/TD]
[TD]8[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Car 1[/TD]
[TD]12[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi James

Your example is not clear.

It seems to me you are just counting how many times "Car1" appears in column A which is a simple countif: =COUNTIF(A1:A3,D1)

You say, however, that you don't want to count column A.

Please clarify.
 
Upvote 0
Apologies for not being clear, let me try again.

Currently I'm using "=COUNTA(B1:B3)" which counts everything if there is a value (not always a number can be letters) if there is nothing in cell it doesn't count it however I need to match D1 to column A1:A3 and if find match then COUNT it, if it's empty then don't count it.

Thank you for baring with me.
 
Upvote 0
Apologies for not being clear, let me try again.

Currently I'm using "=COUNTA(B1:B3)" which counts everything if there is a value (not always a number can be letters) if there is nothing in cell it doesn't count it however I need to match D1 to column A1:A3 and if find match then COUNT it, if it's empty then don't count it.

Thank you for baring with me.

=COUNTIFS(A1:A3,D1,B1:B3,"<>")

If this is also not what you want, try to post a more illustrative sample along with the expected count.
 
Upvote 0
Thanks Aladin that actually gave me a #VALUE ! error however you also gave me a idea which has actually worked!

=SUMPRODUCT((A1:A3=D1)*(B1:B3<>""))

Thanks for your time and patience!
 
Upvote 0
Thanks Aladin that actually gave me a #VALUE ! error however you also gave me a idea which has actually worked!

=SUMPRODUCT((A1:A3=D1)*(B1:B3<>""))

Thanks for your time and patience!

1)

=COUNTIFS(A1:A3,D1,B1:B3,"<>")

2)

=SUMPRODUCT(--(A1:A3=D1),1-(B1:B3=""))

3)

=SUMPRODUCT((A1:A3=D1)*(B1:B3<>""))

are all equivalent. [1] is faster than the other two. [2] complies with the SumProduct specifications better than [3] does.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top