Easy formula Question...counting

thepartydj

Board Regular
Joined
Sep 23, 2004
Messages
247
I would like to get the total count of something only if both columns match.

Example

Column one Column Two
Boy 3
Girl 4
Boy 3
Boy 3
Girl 3
Boy 4

SO if I wanted how many boys are three (3 of them) what would be the formula? Thanks!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

I think SUMPRODUCT is what you need:

=SUMPRODUCT(--(A1:A10="Boy"),--(B1:B10=3))

the criteria can be range references holding the values and obviously amned the ranges in the Sumproduct to suit.

Richard
 

Datsmart

Well-known Member
Joined
Jun 19, 2003
Messages
7,985
Code:
=SUMPRODUCT(--(A2:A7="boy"),--(B2:B7=3),--(B2:B7<>""))
 

thepartydj

Board Regular
Joined
Sep 23, 2004
Messages
247

ADVERTISEMENT

add on to this code.

In column one I might have boy followed by a name in the same cell. How can I add so it only looks at the first word and not the other words in the cell? I tried "boy*" but that doesn't work.
 

thepartydj

Board Regular
Joined
Sep 23, 2004
Messages
247

ADVERTISEMENT

Actually that code doesn't read everything behind boy just like it does with just boy. any other sugesstions
also
How about instead of doing 3 i write it out like "three" what changes in the code because I am trying to put qotes around it like boy but it isn't working. Thanks
 

just_jon

Legend
Joined
Sep 3, 2002
Messages
10,473
If you want to have a variable-length target -- Boy or Girl in cell C1, for example, an the year in C2, then

=SUMPODUCT(--(LEFT(A1:A10,LEN(C1))=C1),--(B1:B10=C2))
 

Forum statistics

Threads
1,136,268
Messages
5,674,734
Members
419,523
Latest member
Urnovio

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
Top