COUNTIF or SUMPRODUCT? Countin two criteria in the same cell

Dippy

New Member
Joined
Jan 10, 2005
Messages
4
I've done a search on this and can find how to count two criteria in different cells, but not two in the same cell.

I've a sheet of text entries, that briefly describe laws. I'd like to count all those with the word "young" in them, but then to discount all those which also have the word "bill" in them, as these are not valid laws, only proposals.

For the first, I have =COUNTIF(B$1:M$33, "*young*") which works perfectly.

For the second, I would imagine SUMPRODUCT counts cells which have young or bill, but not necessarily both.

Please can someone tell me how I add something like AND "*bill*" to the formula above? Or do I need a totally different formula?

Very many thanks!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Re: COUNTIF or SUMPRODUCT? Countin two criteria in the same

=SUMPRODUCT(--ISNUMBER(SEARCH("bill",B$1:M$33)),--ISNUMBER(SEARCH("young",B$1:M$33)))

This expresses the situation in which a cell must have both "bill" and "young" to be counted in.

Addendum: If you want to count "young" but discount cells with "bill" and "young"...

=COUNTIF(B$1:M$33,"*young*")-SUMPRODUCT(--ISNUMBER(SEARCH("bill",B$1:M$33)),--ISNUMBER(SEARCH("young",B$1:M$33)))

If there is more to it, elaborate with examples.
 
Upvote 0
Re: COUNTIF or SUMPRODUCT? Countin two criteria in the same

Hi,

Must it not be:

=SUMPRODUCT(--ISNUMBER(SEARCH("young",B$1:M$33)),--ISERROR(SEARCH("bill",B$1:M$33)))
 
Upvote 0

Forum statistics

Threads
1,214,922
Messages
6,122,281
Members
449,075
Latest member
staticfluids

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