Excel counts the number of times a value appears in a group of columns but counts only one instance of the name per row

我们两清 提交于 2019-12-06 14:00:35

Use OFFSET with SUMPRODUCT. In F7 (per supplied image) as,

=SUMPRODUCT(SIGN(COUNTIF(OFFSET(B$1:E$1, ROW($1:$4)-1, 0), E7)))

The SIGN function turns any positive number to 1 for each row. ROW(1:4) cycles through each of the rows.

Assuming you put your name of choice, e.g. "Ted", in G1, array formula**:

=SUM(0+(MMULT(0+(A1:E4=G1),TRANSPOSE(COLUMN(A1:E4)))>0))

Regards

**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

A non-vba solution with a helper column in column F.

Column F formula =IF(COUNTIF(B1:E1,$I$1)>0,1,0)

J2 formula =SUM(F1:F4)

change I1 as needed for name.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!