Combining SUMPRODUCT and COUNTIF

jme_4477

New Member
Joined
Mar 24, 2016
Messages
43
I'm trying to combine these two formulas:

=SUMPRODUCT((LEN(AS2:AS212)-LEN(SUBSTITUTE(AS2:AS212,"Yes","")))/LEN("Yes"))
=countif(b2:b212="*vermilion*")

Basically, the first formula counts the number of "Yes" in one column, but I need it to only count the "Yes" if another column has "vermilion" in it.

Here's what part of my spreadsheet:

Column B
Column AS
Vermilion High School
Yes, Yes,
Memorial
Yes, No, Yes
South Western
Yes, Yes, Yes, Yes, No

<tbody>
</tbody>


Does anyone know how to do this? I've been working on this for 8 hours!!!

 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Whenever I change the range to go to 212, even when I reconfirm the formula with control+shift+enter, the total changes to #N/A.

Something interesting and confusing.....When I change the range slightly, it works:

=SUM(IF(Sheet2!$B$2:$B$30=$A2,(LEN(Sheet2!$AS$2:$AS$30)-LEN(SUBSTITUTE(UPPER(Sheet2!$AS$2:$AS$30),"YES","")))/LEN("yes")))

It goes up to B30 and AS30 just fine. When I try and go higher, like to B40 and AS40, though, that's when I get the #N/A error in the cell.

Any ideas?
 
Upvote 0
Whenever I change the range to go to 212, even when I reconfirm the formula with control+shift+enter, the total changes to #N/A.

Something interesting and confusing.....When I change the range slightly, it works:

=SUM(IF(Sheet2!$B$2:$B$30=$A2,(LEN(Sheet2!$AS$2:$AS$30)-LEN(SUBSTITUTE(UPPER(Sheet2!$AS$2:$AS$30),"YES","")))/LEN("yes")))

It goes up to B30 and AS30 just fine. When I try and go higher, like to B40 and AS40, though, that's when I get the #N/A error in the cell.

Any ideas?

No problem over here. See the link. Do you have #N/A in B or AS as result of some formula in these columns? By the way, the ranges must be equally sized...
 
Last edited:
Upvote 0
No problem over here. See the link. Do you have #N/A in B or AS as result of some formula in these columns? By the way, the ranges must be equally sized...


That was it!!! Some of my cells in B had N/A in them. YOU ARE AMAZING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Thank you!! :)
 
Upvote 0
I have one final question for you. On my same Totals sheet, I'm trying to count each time "vermilion" appears in B2 to B212. I know I can do it like this: =COUNTIF(Sheet2!B2:B212,"vermilion")

But is there a way to link it back to the A2 cell in my Totals sheet (because A2 in my Totals sheet already has "Vermilion" in the cell)? I think it would be something like this, but it's not working: =COUNTIF(Sheet2!$B$2:$B$212=$A2)
 
Upvote 0
I have one final question for you. On my same Totals sheet, I'm trying to count each time "vermilion" appears in B2 to B212. I know I can do it like this: =COUNTIF(Sheet2!B2:B212,"vermilion")

But is there a way to link it back to the A2 cell in my Totals sheet (because A2 in my Totals sheet already has "Vermilion" in the cell)? I think it would be something like this, but it's not working: =COUNTIF(Sheet2!$B$2:$B$212=$A2)

Again that Vermilion?

=COUNTIFS(Sheet2!$B$2:$B$212,"*"&$A2&"*")
 
Upvote 0

Forum statistics

Threads
1,216,743
Messages
6,132,463
Members
449,729
Latest member
davelevnt

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