How to count cells that contain specific words in two columns

d4d4ng

New Member
Joined
Sep 15, 2011
Messages
8
Hi All,

I want to count cells that contain specific words in two columns, as:

Code:
[INDENT]    Column A Column B
[/INDENT]Row 1    apples   red
Row 2    apples   green
Row 3    banana   yellow
Row 4    apples   red
I want to know the formula to count how many cells in column A with apples AND column B with red.

I have tried :

Code:
=countif(and(A1:A4,"apples"),(B1:B4,"red"))
but no go :confused:

Thanks in advance
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
=SUMPRODUCT(--($A$1:$A$4-"apples"), --($B$1:$B$4="red"))

Excel 2007+ gives you another function:

=COUNTIFS(A1:A4, "apples", B1:B4, "red")
 
Upvote 0
Hi All,

I want to count cells that contain specific words in two columns, as:

Code:
[INDENT]   Column A Column B
[/INDENT]Row 1    apples   red
Row 2    apples   green
Row 3    banana   yellow
Row 4    apples   red
I want to know the formula to count how many cells in column A with apples AND column B with red.

I have tried :

Code:
=countif(and(A1:A4,"apples"),(B1:B4,"red"))
but no go :confused:

Thanks in advance
Try one of these...

Use cells to hold the criteria:
  • D1 = apples
  • E1 = red
This formula will work in Excel 2007 and later:

=COUNTIFS(A1:A4,D1,B1:B4,E1)

This formula will work in ALL versions of Excel:

=SUMPRODUCT(--(A1:A4=D1),--(B1:B4=E1))
 
Upvote 0
@jim may, jbeaucaire and T. Valko,

Highly appreciate your prompt responses :)

I will try to implement each of your way, and back to you later, it's nearly midnite in here.

Thank you all.

Best regards,
d4d4ng
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,259
Members
452,901
Latest member
LisaGo

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