简体   繁体   中英

How to reference specific column and row IDs in a COUNTIF formula in Excel?

I have a data sheet that looks like this.

     Proj1 Proj1 Proj1 Proj2 Proj2
Req1.  x    x            o     x       
Req2   x          x            x

I am using the below formula to check range B2:E2 on my data sheet and return results in the second sheet.

=IF(COUNTIF('Data'!B2:E2;"x")>0;"x";IF(COUNTBLANK('Data'!B2:E2)=COLUMNS('Data'!B2:E2);"0";"o"))

However instead of giving this range (B2:E2) in the formula, I would like to reference column & row ids (eg Proj1 & Req1) and run the formula for the data that matches this criteria.

在此处输入图像描述

Try with SUMPRODUCT:

=IF(SUMPRODUCT(--($B$2:$E$5="x")*--($A$2:$A$5=I3))>0,"x",IF(SUMPRODUCT(--($B$2:$E$5="")*--($A$2:$A$5=I3))=4,0,"o"))

I've added manually the 4 because there are 4 columns but you could replace the 4 with COUNTA($B$1:$E$1)

It should look like this if I've understood requirements correctly:

=LET(Proj,$B$1:$F$1,
Req,$A$2:$A$3,
Data,$B$2:$F$3,
Blanks,SUM((Proj=I$1)*(Req=$H2)*(Data="")),
x,SUM((Proj=I$1)*(Req=$H2)*(Data="x")),
IF(x>0,"x",IF(Blanks=COLUMNS(Data),0,"o")))

Just pulled down and across:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM