COUNTIF or SUMPRODUCT? Countin two criteria in the same cell

Dippy

New Member
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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},\$Z\$1:\$Z\$99,\$Y\$1:\$Y\$99),2,False) to lookup Y values to left of Z values.

MrExcel MVP
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.

fairwinds

MrExcel MVP
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)))

Dippy

New Member
Re: COUNTIF or SUMPRODUCT? Countin two criteria in the same

ray: Very many thanks!

Replies
13
Views
670
Replies
2
Views
239
Replies
4
Views
638
Replies
12
Views
575
Replies
1
Views
613

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,152,117
Messages
5,768,218
Members
425,460
Latest member
Astros1243

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?

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

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