Count items in range based on range of criteria

dmatter26

New Member
Joined
Jul 29, 2013
Messages
5
Ok, say I have the following data in a named range, My_Table, A1:D6:

ABCD
112XxTrueTrue
214XxFalseTrue
315XxTrueTrue
411XxFalseFalse
582XxTrueFalse
650XxFalseFalse

<tbody>
</tbody>

Column A is a list of ID#'s.
Column B is names which I don't care about in this example, just included to show spacing between A and C.
Column C, D are sets of True/False criteria.

What I want is, ideally, a formula that would take a set of input ID's, look at the table and give me a count of those ID's with a corresponding True in a variable column (C, D, E, etc.)

So if I have a five row range (preferably non-named, eg. G1:G5) with three values in it:

11
12
82

<tbody>
</tbody>
and am looking for True in Column C, I would have a formula in H1 that gave me a result of 2. Those 3 ID's all appear in column A (that's already a guarantee), but only two of them are flagged as True in Column C. If I was looking at Column D, the result would be 1, since only 1 of them is flagged as true in Column D.

I can do this for a single value in G1:G5, looking at Column C, with

=COUNTIFS(INDEX(My_Table,,1),G1,INDEX(My_Table,,3),TRUE)

but I can't figure out how to scale this to check the entire G1:G5 range with a formula. I know I can build a VBA function to do this, but I just figure there has to be a more... elegant way of doing this with Excels built-in formulas. Help?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,522
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
To count TRUE in column C for all IDs in G1:G5 try

=SUMPRODUCT(COUNTIFS(INDEX(MyTable,,1),G1:G5,INDEX(MyTable,,3),TRUE))

M.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,579
Messages
5,637,209
Members
416,961
Latest member
sigrid6940

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