[英]Count unique non-blank entries in a range
我在Excel中有這樣的數據:
Person1 A A B A C 3
Person2 0
Person3 A B C D E F 6
Person4 A A A 1
我試圖找到一個公式來復制每行最后一個單元格中的數字,即與該人相關聯的唯一元素的數量(不包括空格)。 因此,例如,即使有三個A,Person1也有3個,因為有A,B和C。 列數是固定的/每個人都相同。 值A,B,C等是字符串(與數字相反)。
可以使用公式來完成嗎?
這應該為您工作:
=SUMPRODUCT((B1:G1<>"")/COUNTIF(B1:G1,B1:G1&""))
在工作表中使用的UDF
Public Function GetUniqueCount(ByVal rng As Range) As Long
Dim dict As Object, currCell As Range
Set dict = CreateObject("Scripting.Dictionary")
For Each currCell In rng
If Not IsEmpty(currCell) Then dict(currCell.Value) = 1
Next currCell
GetUniqueCount = dict.Count
End Function
在工作表中使用:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.