# 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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the \$ sign).

#### Aladin Akyurek

##### 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
2
Views
370
Replies
2
Views
128
Replies
1
Views
327
Replies
12
Views
301
Replies
17
Views
515

Threads
1,181,614
Messages
5,930,929
Members
436,767
Latest member
Langaws

### 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

### 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