multiple criteria with a hitch

jberwald

Board Regular
Joined
May 3, 2005
Messages
205
I need excel to calculate how many times this occurs:

That column C contains an X
when column H contains a certain name.

My problem is that column H can contain two names at times (ie John/Harry) and I would want this cell to be counted in both a John calculation and a Harry calculation.

I have tried this, but it only works on cells containing a single name

=SUMPRODUCT(--($C$3:$C211="X"),--($H3:$H211="John"))

Thanks in advance.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

yee388

Well-known Member
Joined
Mar 7, 2004
Messages
1,374
a condition you can use for that is:

Code:
LEN(SUBSITUTE($H3:$H211,"John",""))<LEN($H3:$H211)

Rather than

$H3:$H211="John"

That way if "John" appears anywhere in the cell, it'll count it.

Edited to fix formula not showing up correctly.
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi,

try this
   C  D  E    F     G  H                      
 1       John Harry                           
 2       3    2                               
 3 x                   john                   
 4                     name                   
 5 x                   where does John live ? 
 6 x                   nothing here           
 7 x                   Garry                  
 8                     Harry                  
 9 x                                          
10 x                   Harry & John           
11 x                                          
12 x                   Harry                  

Blad1

[Table-It] version 06 by Erik Van Geit
Code:
RANGE   FORMULA (1st cell)
E2:F2   =SUMPRODUCT(--($C$3:$C$211="X"),--(ISNUMBER(SEARCH(E1,$H$3:$H$211))))

[Table-It] version 06 by Erik Van Geit

kind regards,
Erik
 

Forum statistics

Threads
1,141,155
Messages
5,704,618
Members
421,360
Latest member
Rhodia

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