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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,209
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
Joined
May 15, 2003
Messages
8,638
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
Joined
Jan 10, 2005
Messages
4
Re: COUNTIF or SUMPRODUCT? Countin two criteria in the same

:pray: Very many thanks! :biggrin:
 

Forum statistics

Threads
1,147,688
Messages
5,742,629
Members
423,745
Latest member
rtaylor1987

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