怎么根据某一列的条件来计算另外一列不重复人员的数量
怎么根据某一列的条件来计算另外一列不重复人员的数量F3=SUM(1/COUNTIF($C$3:$C$14,$C$3:$C$14)*($B$3:$B$14=$E3)),三建下拉 =SUM(IFERROR(1/COUNTIFS($B$3:$B$14,E3,$C$3:$C$14,$C$3:$C$14),0))
或
=SUM(($B$3:$B$14=E3)*(1/COUNTIF($C$3:$C$14,$C$3:$C$14)))
都是数组公式。第二个公式sum换成sumproduct的话,可以不用数组 Sub 统计各组人数()
Range("E3:F1000") = ""
Dim arr, brr(), d As Object, i&
Set d = CreateObject("scripting.dictionary")
arr = Range("B2").CurrentRegion
For i = 2 To UBound(arr)
Set d(arr(i, 1)) = CreateObject("scripting.dictionary")
Next
For i = 2 To UBound(arr)
d(arr(i, 1))(arr(i, 2)) = d(arr(i, 1))(arr(i, 2)) + 1
Next
ReDim brr(1 To d.Count, 1 To 2)
For i = 0 To d.Count - 1
brr(i + 1, 1) = d.keys()(i)
brr(i + 1, 2) = d.items()(i).Count
Next
Range("E3").Resize(d.Count, 2) = brr
Set d = Nothing
End Sub E3 公式
=UNIQUE(B3:B19)&""
F3 公式
=ROWS(UNIQUE(FILTER($B$3:$C$14,$B$3:$B$14=E3))) 好嘞,感谢大神 这个太复杂了 =SUMPRODUCT(($B$3:$B$14=E3)*(1/COUNTIF($C$3:$C$14,$C$3:$C$14))) =CONCAT(IF(FIND(MID(CONCAT(IF(E4=$B$3:$B$14,$C$3:$C$14,"")),ROW(1:9),1),CONCAT(IF(E4=$B$3:$B$14,$C$3:$C$14,"")))=ROW(1:9),MID(CONCAT(IF(E4=$B$3:$B$14,$C$3:$C$14,"")),ROW(1:9),1),""))
数组公式三键结束
页:
[1]