COUNTIF with two arguements?

Mr. Walnuts

Board Regular
Joined
Aug 8, 2005
Messages
176
Ok in the sheet below, I am trying to use a COUNTIF function with two arguements. It doesn't seem to be working though. Is there a better way to do it? What I need is this... for example, in cell C14, I need a count of how many married male persons there are in this database at the top. In this instance, the result should be 3. The same thing applies to the rest of the blocks. you get the point I assume. If someone could clue me in to the right direction, I'd love you forever. By the way, this is just an example. the real deal is on a much larger scale with more important information.
Book1
ABCD
1NameGenderMaritalstatusShoeSize
2JosephMMarried8
3ThomasMSingle8
4JamesMSingle8
5GaryMMarried9
6JackieFMarried10
7HermanMMarried8
8CarmenFSingle9
9JessicaFMarried7
10
11
12
13MarriedSingle
14Male
15Female
16
17Shoesize
188
199
Sheet1
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Richard Schollar

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

=SUMPRODUCT(--($B$2:$B$9="M"),--($C$2:$C$9="Married"))

The criteria (ie "M" and "Married") can be cell references holding these values.

Richard
 

Mr. Walnuts

Board Regular
Joined
Aug 8, 2005
Messages
176
Out of curiosity... what is the "--" for in the formula? I understand the principle behind the formula, I just dont understand why it doesn't work without the dashes.

thank you by the way
 
L

Legacy 51064

Guest
This works as well:


=SUMPRODUCT(($B$2:$B$9="M")*($C$2:$C$9="Married"))
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
The double negative sign basically forces Excel to convert the array of True/Falses to 1s and 0s. Equally, +0 or *1 could be used:

=SUMPRODUCT(($B$2:$B$9="M")+0,($C$2:$C$9="Married")+0)

=SUMPRODUCT(($B$2:$B$9="M")*1,($C$2:$C$9="Married")*1)

This works on the basis of:

True*1
True+0
--True

all equal 1 and

False*1
False+0
--False

all equal 0.

Hope this helps!

Richard
 

Watch MrExcel Video

Forum statistics

Threads
1,114,675
Messages
5,549,363
Members
410,911
Latest member
AniEx
Top