COUNTIF with vertical and horizontal criteria

Jubert

New Member
Joined
Jun 1, 2016
Messages
28
Is it possible to derive a countif using two variables - one horizontal and one vertical. Please see example below
Excel 2010
ABCDEFGHI
2,4572,4572,340944--
1,5072,9192,7803,0582,9193,058
3,360-----
1,7011,7011,6201,485--
2,4572,4572,3402,5742,4571,993
2,7942,8882,7503,0252,8883,025
1,6693,2343,0803,3883,2343,388
2342,4152,3002,5302,4152,530
-4542,1602,3762,2682,376
373560----
7622,6252,5002,7502,6252,750
793-----
------
MonthPersonCount
LG

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #BAD80A"]Person[/TD]
[TD="bgcolor: #A5A39E, align: center"]Mar-16[/TD]
[TD="bgcolor: #A5A39E, align: center"]Apr-16[/TD]
[TD="bgcolor: #A5A39E, align: center"]May-16[/TD]
[TD="bgcolor: #A5A39E, align: center"]Jun-16[/TD]
[TD="bgcolor: #A5A39E, align: center"]Jul-16[/TD]
[TD="bgcolor: #A5A39E, align: center"]Aug-16[/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFFC5, align: center"]LG[/TD]

[TD="align: right"][/TD]

[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFFC5, align: center"]LG[/TD]

[TD="align: right"][/TD]

[TD="align: center"]4[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFFC5, align: center"]Ed[/TD]

[TD="align: right"][/TD]

[TD="align: center"]5[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFFC5, align: center"]LG[/TD]

[TD="align: right"][/TD]

[TD="align: center"]6[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFFC5, align: center"]He[/TD]

[TD="align: right"][/TD]

[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFFC5, align: center"]LG[/TD]

[TD="align: right"][/TD]

[TD="align: center"]8[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFFC5, align: center"]LG[/TD]

[TD="align: right"][/TD]

[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFFC5, align: center"]CG[/TD]

[TD="align: right"][/TD]

[TD="align: center"]10[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFFC5, align: center"]Rg[/TD]

[TD="align: right"][/TD]

[TD="align: center"]11[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFFC5, align: center"]LG[/TD]

[TD="align: right"][/TD]

[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFFC5, align: center"]Ed[/TD]

[TD="align: right"][/TD]

[TD="align: center"]13[/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFFC5, align: center"]LG[/TD]

[TD="align: right"][/TD]

[TD="align: center"]14[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]15[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]16[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]17[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]18[/TD]
[TD="align: right"][/TD]
[TD="align: right"]Apr-16[/TD]

[TD="bgcolor: #92D050, align: right"]6[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet1



I wish to put a formula in D18 which gives me a count for the number of cells >0 that are in the column denoted by cell B18 for the person denoted in cell C18.
Thanks
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
try this array formula

=SUM(IF((C1:H1=A18)*(B2:B13=B18)*(C2:H13<>""),1,0))
 
Upvote 0
Or you could use COUNTIFS, OFFSET and MATCH like this:

Code:
=COUNTIFS($B$2:$B$13, $C$18, OFFSET($B$2, 0, MATCH($B$18, $C$1:$H$1, 0), 12, 1), ">0")

WBD
 
Upvote 0
try this

=COUNTIFS($B$2:$B$13,C18,INDEX($C$2:$H$13,,MATCH(B18,$C$1:$H$1,0)),">0")
 
Upvote 0
Thanks AlanY and wideboydixon - both of those did exactly what I wanted.
(Azumi I didn't get that to work for my example).
 
Upvote 0

Forum statistics

Threads
1,223,226
Messages
6,170,843
Members
452,360
Latest member
abishekjmichael

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