Countifs to refer to cell

RockEd

Board Regular
Joined
Aug 13, 2021
Messages
80
Office Version
  1. 365
Platform
  1. Windows
Hello I'm struggling to search for the right answer to this, and I'm sure it's simple but could do with some help please!

I have a set of data where I want to count the number of times the something comes up (lets say a list of animals), and multiple sizes e.g.

AnimalSize
PigVery small
PigSmall
DogLarge
DogMedium
CatSmall
DogSmall
MouseMedium
DeerSmall

I now want to count say, dogs that are large and medium only.

This works: =sum(countifs(A2:A9,"Dog",B2:B9,{"large", "medium"}))

However how do I get the formula to refer to cells for the size of the animal; i.e. lets say the words "Large" and "Medium" were in C1 and C2 respectfully, this formula doesn't work:

=sum(countifs(A2:A9,"Dog",B2:B9,{C1,C2}))

Any help would be much appreciated!

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
You cannot use cell references in an array like that, try
Excel Formula:
=sum(countifs(A2:A9,"Dog",B2:B9,C1:C2))
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,158
Members
452,892
Latest member
yadavagiri

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