Count cells with “Apple” only in rows that matches the name

kevkev

New Member
Joined
Dec 1, 2019
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I'm trying to create a spreadsheet that counts the number of a particular occurrence on a row only when it matches the name.

Cover Sheet
Col ACol B
Row 1BOB=SUMPRODUCT((General!$A:$A=Cover!A1)*((General!$B:$FZ="Apple")))
Row 2JANE
Row 3JOE
Row 4JOHN

General Sheet
Col ACol BCol C...Col FZ
Row 1JANEAppleOrangeApple
Row 2BOBOrangeAppleOrange
Row 3JOHNAppleAppleApple
Row 4JOEOrangeAppleApple

So far I have this formula =SUMPRODUCT((General!$A:$A=Cover!A1)*((General!$B:$FZ="Apple"))) which works well for small data but it gives the "Excel ran out of resources while attempting to calculate one or more formulas. As a result, these formulas can not be evaluated." when applied to big data (200 rows and 160 columns. File size 97kb). The result of this formula is '1', which is what's expected. I've tried to convert "CountIf" but I can't get it to give the expected results. Help please!
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
60,321
Office Version
  1. 365
Platform
  1. Windows
Never you whole columns in an array formula, you should always limit them to the data, or a few rows extra.
Try
=SUMPRODUCT((General!$A1:$A500=Cover!A1)*((General!$B1:$FZ500="Apple")))
 

kevkev

New Member
Joined
Dec 1, 2019
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Thanks Fluff. Reducing the number of rows worked like magic. It actually skipped my mind cos when I used the whole columns and rows on CountIf, it didn't throw the "ran out of resources" error, just the formula I tried using was giving the wrong result. Can this formula be converted to a CountIf??
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
60,321
Office Version
  1. 365
Platform
  1. Windows
Can this formula be converted to a CountIf??
You would need to use Countifs rather than Countif, but not sure it could be done. Sumproduct is probably the better option.
 

kevkev

New Member
Joined
Dec 1, 2019
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Oh! Okay. I've tried both CountIf and CountIfs but I couldn't get it to work. I'll do with this SumProduct solution. Thanks again for your help!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
60,321
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback
 

Forum statistics

Threads
1,137,124
Messages
5,679,746
Members
419,855
Latest member
Eddier32

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